got icarus verilog model of QSPI working and it returns the same FFFFFFF
[ls2.git] / src / simsoc_hyperram_tb.v
1 // Copyright (c) 2020 LambdaConcept <contact@lambdaconcept.com>
2 // Copyright (c) 2021 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
3
4 `timescale 1 ns / 1 ns
5
6 module simsoc_hyperram_tb;
7 // GSR & PUR init requires for Lattice models
8 GSR GSR_INST (
9 .GSR(1'b1)
10 );
11 PUR PUR_INST (
12 .PUR (1'b1)
13 );
14
15 reg clkin;
16 wire sync;
17 wire sync2x;
18 wire dramsync;
19 wire init;
20
21 // Generate 100 Mhz clock
22 always
23 begin
24 clkin = 1;
25 #5;
26 clkin = 0;
27 #5;
28 end
29
30 // Outputs
31 wire o_csn0;
32 wire o_clk;
33 wire o_resetn;
34
35 // Bidirs
36 wire [7:0] io_dq;
37 wire io_rwds;
38
39 // SPI
40 wire spi_cs_n;
41 wire spi_rst_n;
42 wire [3:0] io_spi_dq;
43
44 s27kl0641
45 #(
46 .TimingModel("S27KL0641DABHI000"))
47 hyperram (
48 .DQ7(io_dq[7]),
49 .DQ6(io_dq[6]),
50 .DQ5(io_dq[5]),
51 .DQ4(io_dq[4]),
52 .DQ3(io_dq[3]),
53 .DQ2(io_dq[2]),
54 .DQ1(io_dq[1]),
55 .DQ0(io_dq[0]),
56 .RWDS(io_rwds),
57 .CSNeg(o_csn0),
58 .CK(o_clk),
59 .RESETNeg(o_resetn)
60 );
61
62 // uart, LEDs, switches
63 wire uart_tx ;
64 reg uart_rx = 0;
65 wire led_0;
66 wire led_1;
67 wire led_2;
68 wire led_3;
69 wire led_4;
70 wire led_5;
71 wire led_6;
72 wire led_7;
73 //reg switch_0 = 0;
74 //reg switch_1 = 0;
75 //reg switch_2 = 0;
76 //reg switch_3 = 0;
77 //reg switch_4 = 0;
78 //reg switch_5 = 0;
79 //reg switch_6 = 0;
80 //reg switch_7 = 0;
81
82 top simsoctop (
83 // hyperram
84 .hyperram_0__cs_n__io(o_csn0),
85 .hyperram_0__rst_n__io(o_resetn),
86 .hyperram_0__rwds__io(io_rwds),
87 .hyperram_0__ck__io(o_clk),
88 .hyperram_0__dq__io(io_dq),
89 // Quad SPI
90 //.spi_flash_4x_0__dq__io(io_spi_dq),
91 //.spi_flash_4x_0__cs__io(spi_cs_n),
92 .spi_0_0__dq__io(io_spi_dq),
93 .spi_0_0__cs_n__io(spi_cs_n),
94
95 // uart
96 .uart_0__rx__io(uart_rx),
97 .uart_0__tx__io(uart_tx),
98 // led
99 .led_0__io(led_0),
100 .led_1__io(led_1),
101 .led_2__io(led_2),
102 .led_3__io(led_3),
103 .led_4__io(led_4),
104 .led_5__io(led_5),
105 .led_6__io(led_6),
106 .led_7__io(led_7),
107 // switches
108 //.switch_0__io(switch_0),
109 //.switch_1__io(switch_1),
110 //.switch_2__io(switch_2),
111 //.switch_3__io(switch_3),
112 //.switch_4__io(switch_4),
113 //.switch_5__io(switch_5),
114 //.switch_6__io(switch_6),
115 //.switch_7__io(switch_7),
116 // clock/reset
117 .clk100_0__p(clkin),
118 .rst_0__io(1'b0)
119 );
120
121 cy15b104qs cy15b104qs
122 (
123 .CSNeg(spi_cs_n),
124 .SCK(simsoctop.spi0.spi_clk),
125 .RESETNeg(io_spi_dq[3]),
126 .SO(io_spi_dq[0]),
127 .SI(io_spi_dq[1]),
128 .WPNeg(io_spi_dq[2])
129 );
130
131 initial
132 begin
133 $dumpfile("simsoc_hyperram.fst");
134 $dumpvars(0, clkin);
135 $dumpvars(0, o_resetn);
136 $dumpvars(0, o_csn0);
137 $dumpvars(0, o_clk);
138 $dumpvars(0, io_rwds);
139 $dumpvars(0, io_dq);
140 $dumpvars(0, uart_tx);
141 $dumpvars(0, uart_rx);
142 $dumpvars(0, simsoctop);
143 end
144
145 initial
146 begin
147
148 // run for a set time period then exit
149 #120000000;
150
151 $finish;
152 end
153
154 endmodule