mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-13 01:16:16 +00:00
Add new tests.
This commit is contained in:
parent
eb0a5b2293
commit
d144748401
10 changed files with 200 additions and 0 deletions
19
tests/ice40/alu.v
Normal file
19
tests/ice40/alu.v
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
module top (
|
||||||
|
input clock,
|
||||||
|
input [31:0] dinA, dinB,
|
||||||
|
input [2:0] opcode,
|
||||||
|
output reg [31:0] dout
|
||||||
|
);
|
||||||
|
always @(posedge clock) begin
|
||||||
|
case (opcode)
|
||||||
|
0: dout <= dinA + dinB;
|
||||||
|
1: dout <= dinA - dinB;
|
||||||
|
2: dout <= dinA >> dinB;
|
||||||
|
3: dout <= $signed(dinA) >>> dinB;
|
||||||
|
4: dout <= dinA << dinB;
|
||||||
|
5: dout <= dinA & dinB;
|
||||||
|
6: dout <= dinA | dinB;
|
||||||
|
7: dout <= dinA ^ dinB;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
endmodule
|
11
tests/ice40/alu.ys
Normal file
11
tests/ice40/alu.ys
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
read_verilog alu.v
|
||||||
|
hierarchy -top top
|
||||||
|
proc
|
||||||
|
flatten
|
||||||
|
equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check
|
||||||
|
design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design)
|
||||||
|
cd top # Constrain all select calls below inside the top module
|
||||||
|
select -assert-count 62 t:SB_CARRY
|
||||||
|
select -assert-count 32 t:SB_DFF
|
||||||
|
select -assert-count 655 t:SB_LUT4
|
||||||
|
select -assert-none t:SB_CARRY t:SB_DFF t:SB_LUT4 %% t:* %D
|
17
tests/ice40/counter.v
Normal file
17
tests/ice40/counter.v
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
module top (
|
||||||
|
out,
|
||||||
|
clk,
|
||||||
|
reset
|
||||||
|
);
|
||||||
|
output [7:0] out;
|
||||||
|
input clk, reset;
|
||||||
|
reg [7:0] out;
|
||||||
|
|
||||||
|
always @(posedge clk, posedge reset)
|
||||||
|
if (reset) begin
|
||||||
|
out <= 8'b0 ;
|
||||||
|
end else
|
||||||
|
out <= out + 1;
|
||||||
|
|
||||||
|
|
||||||
|
endmodule
|
11
tests/ice40/counter.ys
Normal file
11
tests/ice40/counter.ys
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
read_verilog counter.v
|
||||||
|
hierarchy -top top
|
||||||
|
proc
|
||||||
|
flatten
|
||||||
|
equiv_opt -map +/ice40/cells_sim.v synth_ice40 # equivalency check
|
||||||
|
design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design)
|
||||||
|
cd top # Constrain all select calls below inside the top module
|
||||||
|
select -assert-count 7 t:SB_CARRY
|
||||||
|
select -assert-count 8 t:SB_DFFR
|
||||||
|
select -assert-count 8 t:SB_LUT4
|
||||||
|
select -assert-none t:SB_CARRY t:SB_DFFR t:SB_LUT4 %% t:* %D
|
73
tests/ice40/fsm.v
Normal file
73
tests/ice40/fsm.v
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
module fsm (
|
||||||
|
clock,
|
||||||
|
reset,
|
||||||
|
req_0,
|
||||||
|
req_1,
|
||||||
|
gnt_0,
|
||||||
|
gnt_1
|
||||||
|
);
|
||||||
|
input clock,reset,req_0,req_1;
|
||||||
|
output gnt_0,gnt_1;
|
||||||
|
wire clock,reset,req_0,req_1;
|
||||||
|
reg gnt_0,gnt_1;
|
||||||
|
|
||||||
|
parameter SIZE = 3 ;
|
||||||
|
parameter IDLE = 3'b001,GNT0 = 3'b010,GNT1 = 3'b100,GNT2 = 3'b101 ;
|
||||||
|
|
||||||
|
reg [SIZE-1:0] state;
|
||||||
|
reg [SIZE-1:0] next_state;
|
||||||
|
|
||||||
|
always @ (posedge clock)
|
||||||
|
begin : FSM
|
||||||
|
if (reset == 1'b1) begin
|
||||||
|
state <= #1 IDLE;
|
||||||
|
gnt_0 <= 0;
|
||||||
|
gnt_1 <= 0;
|
||||||
|
end else
|
||||||
|
case(state)
|
||||||
|
IDLE : if (req_0 == 1'b1) begin
|
||||||
|
state <= #1 GNT0;
|
||||||
|
gnt_0 <= 1;
|
||||||
|
end else if (req_1 == 1'b1) begin
|
||||||
|
gnt_1 <= 1;
|
||||||
|
state <= #1 GNT0;
|
||||||
|
end else begin
|
||||||
|
state <= #1 IDLE;
|
||||||
|
end
|
||||||
|
GNT0 : if (req_0 == 1'b1) begin
|
||||||
|
state <= #1 GNT0;
|
||||||
|
end else begin
|
||||||
|
gnt_0 <= 0;
|
||||||
|
state <= #1 IDLE;
|
||||||
|
end
|
||||||
|
GNT1 : if (req_1 == 1'b1) begin
|
||||||
|
state <= #1 GNT2;
|
||||||
|
gnt_1 <= req_0;
|
||||||
|
end
|
||||||
|
GNT2 : if (req_0 == 1'b1) begin
|
||||||
|
state <= #1 GNT1;
|
||||||
|
gnt_1 <= req_1;
|
||||||
|
end
|
||||||
|
default : state <= #1 IDLE;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module top (
|
||||||
|
input clk,
|
||||||
|
input rst,
|
||||||
|
input a,
|
||||||
|
input b,
|
||||||
|
output g0,
|
||||||
|
output g1
|
||||||
|
);
|
||||||
|
|
||||||
|
fsm u_fsm ( .clock(clk),
|
||||||
|
.reset(rst),
|
||||||
|
.req_0(a),
|
||||||
|
.req_1(b),
|
||||||
|
.gnt_0(g0),
|
||||||
|
.gnt_1(g1));
|
||||||
|
|
||||||
|
endmodule
|
13
tests/ice40/fsm.ys
Normal file
13
tests/ice40/fsm.ys
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
read_verilog fsm.v
|
||||||
|
hierarchy -top top
|
||||||
|
proc
|
||||||
|
flatten
|
||||||
|
equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check
|
||||||
|
design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design)
|
||||||
|
cd top # Constrain all select calls below inside the top module
|
||||||
|
|
||||||
|
select -assert-count 2 t:SB_DFFESR
|
||||||
|
select -assert-count 2 t:SB_DFFSR
|
||||||
|
select -assert-count 1 t:SB_DFFSS
|
||||||
|
select -assert-count 13 t:SB_LUT4
|
||||||
|
select -assert-none t:SB_DFFESR t:SB_DFFSR t:SB_DFFSS t:SB_LUT4 %% t:* %D
|
18
tests/ice40/logic.v
Normal file
18
tests/ice40/logic.v
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
module top
|
||||||
|
(
|
||||||
|
input [0:7] in,
|
||||||
|
output B1,B2,B3,B4,B5,B6,B7,B8,B9,B10
|
||||||
|
);
|
||||||
|
|
||||||
|
assign B1 = in[0] & in[1];
|
||||||
|
assign B2 = in[0] | in[1];
|
||||||
|
assign B3 = in[0] ~& in[1];
|
||||||
|
assign B4 = in[0] ~| in[1];
|
||||||
|
assign B5 = in[0] ^ in[1];
|
||||||
|
assign B6 = in[0] ~^ in[1];
|
||||||
|
assign B7 = ~in[0];
|
||||||
|
assign B8 = in[0];
|
||||||
|
assign B9 = in[0:1] && in [2:3];
|
||||||
|
assign B10 = in[0:1] || in [2:3];
|
||||||
|
|
||||||
|
endmodule
|
7
tests/ice40/logic.ys
Normal file
7
tests/ice40/logic.ys
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
read_verilog logic.v
|
||||||
|
hierarchy -top top
|
||||||
|
equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check
|
||||||
|
design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design)
|
||||||
|
cd top # Constrain all select calls below inside the top module
|
||||||
|
select -assert-count 9 t:SB_LUT4
|
||||||
|
select -assert-none t:SB_LUT4 %% t:* %D
|
22
tests/ice40/shifter.v
Normal file
22
tests/ice40/shifter.v
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
module top (
|
||||||
|
out,
|
||||||
|
clk,
|
||||||
|
in
|
||||||
|
);
|
||||||
|
output [7:0] out;
|
||||||
|
input signed clk, in;
|
||||||
|
reg signed [7:0] out = 0;
|
||||||
|
|
||||||
|
always @(posedge clk)
|
||||||
|
begin
|
||||||
|
`ifndef BUG
|
||||||
|
out <= out >> 1;
|
||||||
|
out[7] <= in;
|
||||||
|
`else
|
||||||
|
|
||||||
|
out <= out << 1;
|
||||||
|
out[7] <= in;
|
||||||
|
`endif
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
9
tests/ice40/shifter.ys
Normal file
9
tests/ice40/shifter.ys
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
read_verilog shifter.v
|
||||||
|
hierarchy -top top
|
||||||
|
proc
|
||||||
|
flatten
|
||||||
|
equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check
|
||||||
|
design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design)
|
||||||
|
cd top # Constrain all select calls below inside the top module
|
||||||
|
select -assert-count 8 t:SB_DFF
|
||||||
|
select -assert-none t:SB_DFF %% t:* %D
|
Loading…
Add table
Add a link
Reference in a new issue