From 89ad9fc85a4e89a8ae1ac977412d54de274ed02d Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 8 Aug 2017 12:07:17 +0200 Subject: [PATCH] Fix bug in picosoc spimemio and some cleanups in hx8kdemo --- picosoc/hx8kdemo.pcf | 16 ++++++++-------- picosoc/hx8kdemo.v | 29 +++++++++++++++++++---------- picosoc/spimemio.v | 2 ++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/picosoc/hx8kdemo.pcf b/picosoc/hx8kdemo.pcf index c6bf0d9..8e082f8 100644 --- a/picosoc/hx8kdemo.pcf +++ b/picosoc/hx8kdemo.pcf @@ -13,12 +13,12 @@ set_io flash_io3 P8 # center on J3 set_io ser_tx B12 set_io ser_rx B10 -set_io leds[0] B5 # LED0 -set_io leds[1] B4 # LED1 -set_io leds[2] A2 # LED2 -set_io leds[3] A1 # LED3 -set_io leds[4] C5 # LED4 -set_io leds[5] C4 # LED5 -set_io leds[6] B3 # LED6 -set_io leds[7] C3 # LED7 +set_io leds[7] B5 # D9 +set_io leds[6] B4 # D8 +set_io leds[5] A2 # D7 +set_io leds[4] A1 # D6 +set_io leds[3] C5 # D5 +set_io leds[2] C4 # D4 +set_io leds[1] B3 # D3 +set_io leds[0] C3 # D2 diff --git a/picosoc/hx8kdemo.v b/picosoc/hx8kdemo.v index 42adcc5..db4d9a8 100644 --- a/picosoc/hx8kdemo.v +++ b/picosoc/hx8kdemo.v @@ -62,22 +62,31 @@ module hx8kdemo ( reg [31:0] iomem_rdata; reg [31:0] gpio; + reg [4:0] gpio_shr; - assign leds = gpio >> 12; + assign leds = gpio >> gpio_shr; always @(posedge clk) begin - iomem_ready <= 0; - if (iomem_valid && !iomem_ready && iomem_addr[31:24] == 8'h 02) begin - iomem_ready <= 1; - iomem_rdata <= gpio; - if (iomem_wstrb[0]) gpio[ 7: 0] <= iomem_wdata[ 7: 0]; - if (iomem_wstrb[1]) gpio[15: 8] <= iomem_wdata[15: 8]; - if (iomem_wstrb[2]) gpio[23:16] <= iomem_wdata[23:16]; - if (iomem_wstrb[3]) gpio[31:24] <= iomem_wdata[31:24]; + if (!resetn) begin + gpio <= 0; + gpio_shr <= 0; + end else begin + iomem_ready <= 0; + if (iomem_valid && !iomem_ready && iomem_addr[31:24] == 8'h 02) begin + iomem_ready <= 1; + iomem_rdata <= gpio; + if (iomem_wstrb[0]) gpio[ 7: 0] <= iomem_wdata[ 7: 0]; + if (iomem_wstrb[1]) gpio[15: 8] <= iomem_wdata[15: 8]; + if (iomem_wstrb[2]) gpio[23:16] <= iomem_wdata[23:16]; + if (iomem_wstrb[3]) gpio[31:24] <= iomem_wdata[31:24]; + end + if (&leds && gpio_shr < 10) begin + gpio_shr <= gpio_shr + 1; + end end end - picosoc uut ( + picosoc soc ( .clk (clk ), .resetn (resetn ), diff --git a/picosoc/spimemio.v b/picosoc/spimemio.v index 93227cb..1535aea 100644 --- a/picosoc/spimemio.v +++ b/picosoc/spimemio.v @@ -105,6 +105,7 @@ module spimemio ( state <= 0; xfer_resetn <= 0; rd_valid <= 0; + buffer_wen <= 0; din_cont <= 0; din_qspi <= 0; din_ddr <= 0; @@ -220,6 +221,7 @@ module spimemio ( rd_inc <= 0; rd_valid <= 0; xfer_resetn <= 0; + buffer_wen <= 0; state <= 4; end end