code
stringlengths
35
6.69k
score
float64
6.5
11.5
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = (~R[Aad]); assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = '0; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = '1; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input reset, output [3:0] q ); always @(posedge clk) begin if (reset) q <= 4'd1; else if (q == 4'd10) q <= 4'd1; else q <= q + 1; end endmodule
7.203305
module top_module ( input clk, input reset, output reg [3:0] q ); always @(posedge clk) begin if (reset) q <= 4'b0001; else if (q == 4'b1010) q <= 4'b0001; else q <= q + 1; end endmodule
7.203305
module top_module ( input clk, input slowena, input reset, output [3:0] q ); always @(posedge clk) begin if (reset | (slowena & (q == 9))) q <= 0; else q <= (slowena) ? q + 1 : q; end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = (~R[Bad]); assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = '0; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = '1; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input slowena, input reset, output [3:0] q ); always @(posedge clk) begin if (reset) q <= 4'b0; else if (q == 4'd9 & slowena) q <= 4'b0; else if (slowena) q <= q + 1; end endmodule
7.203305
module top_module ( input clk, input slowena, input reset, output reg [3:0] q ); always @(posedge clk) begin if (reset) q <= 0; else if (slowena) if (q == 4'b1001) q <= 0; else q <= q + 1; end endmodule
7.203305
module top_module ( input clk, input reset, input enable, output [3:0] Q, output c_enable, output c_load, output [3:0] c_d ); // initial Q <= 1; always @(posedge clk) begin if (reset | ((Q == 12) & enable)) Q <= 1; else Q <= (enable) ? Q + 1 : Q; end assign c_enable = enable; assign c_load = (reset | ((Q == 12) & enable)); assign c_d = c_load ? 1 : 0; count4 the_counter ( clk, c_enable, c_load, c_d /*, ... */ ); endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = ((!ue[3]) && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = ('0 && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = ('1 && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && (!store)); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && '0); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && '1); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] || store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input reset, input enable, output [3:0] Q, output c_enable, output c_load, output [3:0] c_d ); // assign c_enable = enable; assign c_load = (reset | (Q == 4'd12 & c_enable)) ? 4'd1 : 4'd0; assign c_d = (reset | (Q == 4'd12 & c_enable)) ? 4'd1 : 4'd0; count4 the_counter ( .clk(clk), .enable(c_enable), .load(c_load), .d(c_d), .Q(Q) ); endmodule
7.203305
module top_module ( input clk, input reset, input enable, output reg [3:0] Q, output c_enable, output reg c_load, output [3:0] c_d ); // wire [3:0] Q_temp; assign c_enable = enable ? 1 : 1'b0; assign c_d = c_load ? 1'b1 : 1'b0; always @(posedge clk) begin if (reset) Q <= 4'b0001; else if (enable) if (Q != 4'b1100) Q <= Q + 1; else Q <= 4'b0001; end always @(*) begin if (reset || (enable && Q == 4'b1100)) c_load = 1'b1; else c_load = 1'b0; end // 用于验证 count4 u_count4 ( .clk(clk), .enable(enable), .load(c_load), .d(c_d), .Q(Q_temp) ); endmodule
7.203305
module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable ); // wire [3:0] q0, q1, q2; bcdcount counter0 ( clk, reset, c_enable[0], q0 ); bcdcount counter1 ( clk, reset, c_enable[1], q1 ); bcdcount counter2 ( clk, reset, c_enable[2], q2 ); assign c_enable = {(q1 == 4'd9) & (q0 == 4'd9), q0 == 4'd9, 1'b1}; assign OneHertz = (q2 == 4'd9) & (q1 == 4'd9) & (q0 == 4'd9); endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (~(ue[3] && store)); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = '0; assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = '1; assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module shan1293_2bitalu ( input [7:0] io_in, output [7:0] io_out ); alu alu ( .A(io_in[7:6]), .B(io_in[5:4]), .opcode(io_in[3:0]), .ALU_Out(io_out[7:0]) ); endmodule
7.155259
module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable ); // wire [3:0] counter0_Q, counter1_Q, counter2_Q; assign c_enable[0] = ~reset; assign c_enable[1] = (c_enable[0]) & (counter0_Q == 4'd9); assign c_enable[2] = (c_enable[1]) & (counter1_Q == 4'd9); assign OneHertz = (c_enable[2]) & (counter2_Q == 4'd9); bcdcount counter0 ( .clk(clk), .reset(reset), .enable(c_enable[0]), .Q(counter0_Q) ); bcdcount counter1 ( .clk(clk), .reset(reset), .enable(c_enable[1]), .Q(counter1_Q) ); bcdcount counter2 ( .clk(clk), .reset(reset), .enable(c_enable[2]), .Q(counter2_Q) ); endmodule
7.203305
module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable ); // wire [3:0] q0; wire [3:0] q1; wire [3:0] q2; bcdcount counter0 ( clk, reset, c_enable[0], q0 ); bcdcount counter1 ( clk, reset, c_enable[1], q1 ); bcdcount counter2 ( clk, reset, c_enable[2], q2 ); assign c_enable = {(q1 == 4'd9) && (q0 == 4'd9), q0 == 4'd9, 1'b1}; assign OneHertz = (q2 == 4'd9) && (q1 == 4'd9) && (q0 == 4'd9); endmodule
7.203305
module top_module ( input clk, input reset, // Synchronous active-high reset output [3:1] ena, output [15:0] q ); //用来表示进位 assign ena = { q[11:8] == 4'd9 && q[7:4] == 4'd9 && q[3:0] == 4'd9, q[7:4] == 4'd9 && q[3:0] == 4'd9, q[3:0] == 4'd9 }; //one count4 inst1_count4 ( .clk(clk), .reset(reset), .ena(1), .q(q[3:0]) ); //ten count4 inst2_count4 ( .clk(clk), .reset(reset), .ena(ena[1]), .q(q[7:4]) ); //hundred count4 inst3_count4 ( .clk(clk), .reset(reset), .ena(ena[2]), .q(q[11:8]) ); //thousand count4 inst4_count4 ( .clk(clk), .reset(reset), .ena(ena[3]), .q(q[15:12]) ); endmodule
7.203305
module count4 ( input clk, input reset, input ena, output reg [3:0] q ); always @(posedge clk) begin if (reset) q <= 4'd0; else begin if (ena) begin if (q == 4'd9) q <= 4'd0; else q <= q + 1; end end end endmodule
7.148055
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = (~MDRw); always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = '0; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = '1; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input reset, // Synchronous active-high reset output [3:1] ena, output [15:0] q ); wire ena_0; always @(posedge clk or negedge reset) begin if (~reset) ena_0 <= 1; else ena_0 <= 0; end // assign ena3_0[0] = ~reset; assign ena[1] = (ena_0) & (q[3:0] == 4'd9); assign ena[2] = (ena[1]) & (q[7:4] == 4'd9); assign ena[3] = (ena[2]) & (q[11:8] == 4'd9); BCD_counter BCD_counter_u0[3:0] ( .clk({4{clk}}), .reset({4{reset}}), .ena({ena, ena_0}), .q(q) ); endmodule
7.203305
module BCD_counter ( input clk, reset, ena, output reg [3:0] q ); always @(posedge clk) begin if (reset) q <= 4'b0; else if (ena) if (q == 4'd9) q <= 4'd0; else q <= q + 1; end endmodule
6.772334
module top_module ( input clk, input reset, // Synchronous active-high reset output reg [3:1] ena, output reg [15:0] q ); always @(posedge clk) begin if (reset) q <= 0; else begin if (q[3:0] == 4'd9) begin q[3:0] <= 4'b0000; if (q[7:4] == 4'd9) begin q[7:4] <= 4'b0000; if (q[11:8] == 4'd9) begin q[11:8] <= 4'b0000; if (q[15:12] == 4'd9) q[15:12] <= 4'b0000; else q[15:12] <= q[15:12] + 1; end else q[11:8] <= q[11:8] + 4'b0001; end else q[7:4] <= q[7:4] + 4'b0001; end else q[3:0] <= q[3:0] + 4'b0001; end end // always @(posedge clk) // begin // if(reset) // q <= 0; // else // begin // q <= q + 1; // end // end always @(posedge clk) begin if (reset) ena <= 0; else begin if (q[3:0] == 4'd8) begin ena[1] <= 1'b1; if (q[7:4] == 4'd9) begin ena[2] <= 1'b1; if (q[11:8] == 4'd9) ena[3] <= 1'b1; end end else ena <= 3'b000; end end endmodule
7.203305
module top_module ( input clk, input reset, input ena, output pm, output [7:0] hh, output [7:0] mm, output [7:0] ss ); reg [2:0] ena_hms; //determine when will "ss","mm" and "hh" need to be increased assign ena_hms = {(ena && (mm == 8'h59) && (ss == 8'h59)), (ena && (ss == 8'h59)), ena}; count60 count_ss ( .clk(clk), .reset(reset), .ena(ena_hms[0]), .q(ss) ); count60 count_mm ( .clk(clk), .reset(reset), .ena(ena_hms[1]), .q(mm) ); always @(posedge clk) begin if (reset) begin hh <= 8'h12; //hh=12 pm <= 0; end else begin if (ena_hms[2]) begin //if mm=59 and ss=59 if (hh == 8'h12) hh <= 8'h1; //hh will change:12AM->1AM or 12PM->1PM else if (hh == 8'h11) begin //if hh=11, then PM->AM or AM->PM hh[3:0] <= hh[3:0] + 1'h1; //hh=12 pm <= ~pm; end else begin if (hh[3:0] == 4'h9) begin hh[3:0] <= 4'h0; hh[7:4] <= hh[7:4] + 1'h1; end else hh[3:0] = hh[3:0] + 1'h1; end end else hh <= hh; end end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge (!clk)) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge 0) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input reset, input ena, output pm, output [7:0] hh, output [7:0] mm, output [7:0] ss ); always @(posedge clk) begin if (reset) ss <= 0; else if (ena) if (ss == 8'h59) ss <= 0; else if (ss[3:0] == 4'h9) ss <= {(ss[7:4] + 1), 4'h0}; else ss <= ss + 1; end always @(posedge clk) begin if (reset) mm <= 0; else if (ena & (ss == 8'h59)) if (mm == 8'h59) mm <= 0; else if (mm[3:0] == 4'h9) mm <= {(mm[7:4] + 1), 4'h0}; else mm <= mm + 1; end always @(posedge clk) begin if (reset) hh <= 8'h12; else if (ena & (ss == 8'h59) & (mm == 8'h59)) if (hh == 8'h12) hh <= 1; else if (hh[3:0] == 4'h9) hh <= {(hh[7:4] + 1), 4'h0}; else hh <= hh + 1; end always @(posedge clk) begin if (reset) pm <= 0; else if (ena & (ss == 8'h59) & (mm == 8'h59) & (hh == 8'h11)) pm <= ~pm; end endmodule
7.203305
module top_module ( input clk, input reset, input ena, output reg pm, output reg [7:0] hh, output reg [7:0] mm, output reg [7:0] ss ); always @(posedge clk) begin if (reset) begin hh <= 8'b0001_0010; mm <= 8'd0; ss <= 8'd0; end else if (ena) begin // ss if (ss[3:0] == 4'b1001) begin if (ss[7:4] == 4'b0101) begin ss <= 8'b0000_0000; // mm if (mm[3:0] == 4'b1001) begin if (mm[7:4] == 4'b0101) begin mm <= 8'b0000_0000; // hh if (hh[3:0] == 4'b1001) begin hh <= {hh[7:4] + 4'b0001, 4'd0000}; end else if (hh == 8'b0001_0010) hh <= 8'b0000_0001; else hh <= hh + 8'b0000_0001; // hh complete end else begin mm <= {{mm[7:4] + 4'b0001}, 4'b0000}; end end else mm <= mm + 8'b0000_0001; // mm complete end else begin ss <= {{ss[7:4] + 4'b0001}, 4'b0000}; end end else begin ss <= ss + 8'b0000_0001; end // ss complete end end // contral pm or am always @(posedge clk) begin if (reset) pm <= 1'b0; else if ((hh == 8'b0001_0001) & (mm == 8'b0101_1001) & (ss == 8'b0101_1001)) pm <= ~pm; end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge 1) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module sky130_fd_sc_hd__dlrtp_1 ( input GATE, RESET_B, D, output reg Q ); always @* if (~RESET_B) Q <= 0; else if (GATE) Q <= D; endmodule
7.212805
module sky130_fd_sc_hd__dlxtp_1 ( input GATE, D, output reg Q ); always @* if (GATE) Q <= D; endmodule
7.212805
module sky130_fd_sc_hd__and3_1 ( input A, B, C, output X ); assign X = A & B & C; endmodule
7.212805
module top_module ( input clk, input areset, // async active-high reset to zero input load, input ena, input [3:0] data, output reg [3:0] q ); always @(posedge clk or posedge areset) begin if (areset) begin q <= 0; end else begin if (load) begin q <= data; end else begin if (ena) begin q <= (q >> 1); end end end end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= (~0); R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= '0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= '1; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input areset, // async active-high reset to zero input load, input ena, input [3:0] data, output reg [3:0] q ); always @(posedge clk or posedge areset) begin if (areset) q <= 0; else if (load) q <= data; else if (ena) q <= {1'b0, q[3:1]}; end endmodule
7.203305
module top_module ( input clk, input areset, // async active-high reset to zero input load, input ena, input [3:0] data, output reg [3:0] q ); always @(posedge clk or posedge areset) begin if (areset) q <= 4'h0; else if (load) q <= data; else if (ena) q <= {1'b0, q[3:1]}; else q <= q; end endmodule
7.203305
module top_module ( input clk, input load, input [1:0] ena, input [99:0] data, output reg [99:0] q ); always @(posedge clk) begin if (load) q <= data; else begin if (ena == 2'b01) q <= {q[0], q[99:1]}; else if (ena == 2'b10) q <= {q[98:0], q[99]}; else q <= q; end end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= (~0); R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= '0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= '1; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input load, input [1:0] ena, input [99:0] data, output reg [99:0] q ); always @(posedge clk) begin if (load) q <= data; else case (ena) 2'b01: q <= {q[0], q[99:1]}; 2'b10: q <= {q[98:0], q[99]}; endcase end endmodule
7.203305
module top_module ( input clk, input load, input [1:0] ena, input [99:0] data, output reg [99:0] q ); always @(posedge clk) begin if (load) q <= data; else begin case (ena) 2'b01: q <= {q[0], q[99:1]}; 2'b10: q <= {q[98:0], q[99]}; default: q <= q; endcase end end endmodule
7.203305
module top_module ( input clk, input load, input ena, input [1:0] amount, input [63:0] data, output reg [63:0] q ); always @(posedge clk) begin if (load) q <= data; else begin if (ena) begin if (amount == 2'b00) q <= (q << 1); else if (amount == 2'b01) q <= (q << 8); else if (amount == 2'b10) begin if (q[63] == 0) q <= (q >> 1); else begin q <= (q >> 1); q[63] <= 1'b1; end end else begin if (q[63] == 0) q <= (q >> 8); else begin q <= (q >> 8); q[63:56] <= {8{1'b1}}; end end end end end endmodule
7.203305
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= (~0); R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= '0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= bus_in; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= '1; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input load, input ena, input [1:0] amount, input [63:0] data, output reg [63:0] q ); always @(posedge clk) begin if (load) q <= data; else if (ena) case (amount) 2'b00: q <= {q[62:0], 1'b0}; 2'b01: q <= {q[55:0], 8'b0}; 2'b10: q <= {q[63], q[63:1]}; 2'b11: q <= {{8{q[63]}}, q[63:8]}; endcase end endmodule
7.203305
module top_module ( input clk, input load, input ena, input [1:0] amount, input [63:0] data, output reg [63:0] q ); always @(posedge clk) begin if (load) q <= data; else if (ena) begin case (amount) 2'b00: q <= {q[62:0], 1'b0}; 2'b01: q <= {q[55:0], 8'h00}; 2'b10: q <= {q[63], q[63], q[62:1]}; 2'b11: q <= {q[63], {8{q[63]}}, q[62:8]}; default: q <= q; endcase end end endmodule
7.203305
module prog_melody_gen ( input [7:0] io_in, output [7:0] io_out ); reg [9:0] div_tmr = 0; reg tick; reg state; reg [7:0] curr_tone; reg [5:0] tone_seq; wire [3:0] rom_rdata; wire clock = io_in[0]; wire reload = io_in[1]; wire restart = io_in[2]; wire pgm_data = io_in[3]; wire pgm_strobe = io_in[4]; assign io_out[7:1] = 1'b0; always @(posedge clock, posedge restart) begin if (restart) begin div_tmr <= 0; tone_seq <= 0; curr_tone <= 0; tick <= 1'b0; state <= 1'b0; end else begin {tick, div_tmr} <= div_tmr + 1'b1; if (tick) begin if (!state) begin tone_seq <= tone_seq + 1'b1; if (rom_rdata == 15) curr_tone <= 0; // silence else curr_tone <= 12 + rom_rdata; // note end else begin curr_tone <= 0; // gap between notes end state <= ~state; end end end reg [7:0] mel_gen = 0; reg mel_out; always @(posedge clock) begin if (mel_gen >= curr_tone) mel_gen <= 0; else mel_gen <= mel_gen + 1'b1; mel_out <= mel_gen > (curr_tone / 2); end assign io_out[0] = mel_out; localparam C = 4'd11, CS = 4'd10, D = 4'd9, E = 4'd7, F = 4'd6, FS = 4'd5, G = 4'd4, GS = 4'd3, A = 4'd2, AS = 4'd1, B = 4'd0, S = 4'd15; localparam [4*64:0] JINGLE_BELS = { E, E, E, S, E, E, E, S, E, G, C, D, E, S, F, F, F, F, F, E, E, E, E, E, D, D, E, D, S, G, S, E, E, E, S, E, E, E, S, E, G, C, D, E, S, F, F, F, F, F, E, E, E, E, F, F, E, D, C, S, S, S, S, S }; wire [ 3:0] tone_rom [0:63]; // program shift register reg [10:0] write_sr; always @(posedge clock) write_sr <= {pgm_data, write_sr[10:1]}; wire [5:0] pgm_word_sel = write_sr[10:5]; wire [3:0] pgm_write_data = write_sr[3:0]; // the tone RAM generate genvar ii; genvar jj; for (ii = 0; ii < 64; ii = ii + 1'b1) begin : words wire word_we; sky130_fd_sc_hd__and2_1 word_we_i ( // make sure this is really glitch free .A(pgm_word_sel == ii), .B(pgm_strobe), .X(word_we) ); for (jj = 0; jj < 4; jj = jj + 1'b1) begin : bits localparam pgm_bit = JINGLE_BELS[(63-ii)*4+jj]; wire lat_o; sky130_fd_sc_hd__dlrtp_1 rfbit_i ( .GATE(word_we), .RESET_B(reload), .D(pgm_write_data[jj]), .Q(lat_o) ); assign tone_rom[ii][jj] = lat_o ^ pgm_bit; end end endgenerate assign rom_rdata = tone_rom[tone_seq]; endmodule
6.923884
module sky130_fd_sc_hd__dlrtp_1 ( input GATE, RESET_B, D, output reg Q ); always @* if (~RESET_B) Q <= 0; else if (GATE) Q <= D; endmodule
7.212805
module sky130_fd_sc_hd__and2_1 ( input A, B, output X ); assign X = A & B; endmodule
7.212805
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= (~bus_in); reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= '0; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module //`define frameIDcount //frameID counts for itself by adding one every frame `define Preamble 64'hd555_5555_5555_5555 //The MAC address of this MAC IP core and the other terminal on the Ethernet, can be changed! `define MAC_ADD 48'h0100_0000_0000 //mac address: 0x00-00-00-00-00-01 `define PC_MAC_ADD 48'hffff_ffff_ffff //mac address of the other terminal `define frameidlen 24 //the id of the MAC frame `define uframelen 148 //148-bit `define num_uframe 8 //the number of uframes received once `define interval 8.25 //the interval between frames without send any data on fifo `define da_offset (8<<1) //8 byte before `define sa_offset (`da_offset+(6<<1)) //8+6 bytes before `define typelen_offset (`sa_offset+(6<<1)) `define frameid_offset (`typelen_offset+(2<<1))//index of first bit of frameid `define data_offset (`frameid_offset+(`frameidlen>>2)) //index of first bit of datamodule CRC_Module(Clk, Reset, Data, Enable, Initialize, Crc, CrcError); input Clk; input Reset; input [3:0] Data; input Enable; //should be valid from the destination address until the data before the CRC checksum input Initialize; //need to initialize before data in output [31:0] Crc; output CrcError; reg [31:0] Crc; wire [31:0] CrcNext; assign CrcNext[0] = Enable & (Data[0] ^ Crc[28]); assign CrcNext[1] = Enable & (Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29]); assign CrcNext[2] = Enable & (Data[2] ^ Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29] ^ Crc[30]); assign CrcNext[3] = Enable & (Data[3] ^ Data[2] ^ Data[1] ^ Crc[29] ^ Crc[30] ^ Crc[31]); assign CrcNext[4] = (Enable & (Data[3] ^ Data[2] ^ Data[0] ^ Crc[28] ^ Crc[30] ^ Crc[31])) ^ Crc[0]; assign CrcNext[5] = (Enable & (Data[3] ^ Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29] ^ Crc[31])) ^ Crc[1]; assign CrcNext[6] = (Enable & (Data[2] ^ Data[1] ^ Crc[29] ^ Crc[30])) ^ Crc[ 2]; assign CrcNext[7] = (Enable & (Data[3] ^ Data[2] ^ Data[0] ^ Crc[28] ^ Crc[30] ^ Crc[31])) ^ Crc[3]; assign CrcNext[8] = (Enable & (Data[3] ^ Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29] ^ Crc[31])) ^ Crc[4]; assign CrcNext[9] = (Enable & (Data[2] ^ Data[1] ^ Crc[29] ^ Crc[30])) ^ Crc[5]; assign CrcNext[10] = (Enable & (Data[3] ^ Data[2] ^ Data[0] ^ Crc[28] ^ Crc[30] ^ Crc[31])) ^ Crc[6]; assign CrcNext[11] = (Enable & (Data[3] ^ Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29] ^ Crc[31])) ^ Crc[7]; assign CrcNext[12] = (Enable & (Data[2] ^ Data[1] ^ Data[0] ^ Crc[28] ^ Crc[29] ^ Crc[30])) ^ Crc[8]; assign CrcNext[13] = (Enable & (Data[3] ^ Data[2] ^ Data[1] ^ Crc[29] ^ Crc[30] ^ Crc[31])) ^ Crc[9]; assign CrcNext[14] = (Enable & (Data[3] ^ Data[2] ^ Crc[30] ^ Crc[31])) ^ Crc[10]; assign CrcNext[15] = (Enable & (Data[3] ^ Crc[31])) ^ Crc[11]; assign CrcNext[16] = (Enable & (Data[0] ^ Crc[28])) ^ Crc[12]; assign CrcNext[17] = (Enable & (Data[1] ^ Crc[29])) ^ Crc[13]; assign CrcNext[18] = (Enable & (Data[2] ^ Crc[30])) ^ Crc[14]; assign CrcNext[19] = (Enable & (Data[3] ^ Crc[31])) ^ Crc[15]; assign CrcNext[20] = Crc[16]; assign CrcNext[21] = Crc[17]; assign CrcNext[22] = (Enable & (Data[0] ^ Crc[28])) ^ Crc[18]; assign CrcNext[23] = (Enable & (Data[1] ^ Data[0] ^ Crc[29] ^ Crc[28])) ^ Crc[19]; assign CrcNext[24] = (Enable & (Data[2] ^ Data[1] ^ Crc[30] ^ Crc[29])) ^ Crc[20]; assign CrcNext[25] = (Enable & (Data[3] ^ Data[2] ^ Crc[31] ^ Crc[30])) ^ Crc[21]; assign CrcNext[26] = (Enable & (Data[3] ^ Data[0] ^ Crc[31] ^ Crc[28])) ^ Crc[22]; assign CrcNext[27] = (Enable & (Data[1] ^ Crc[29])) ^ Crc[23]; assign CrcNext[28] = (Enable & (Data[2] ^ Crc[30])) ^ Crc[24]; assign CrcNext[29] = (Enable & (Data[3] ^ Crc[31])) ^ Crc[25]; assign CrcNext[30] = Crc[26]; assign CrcNext[31] = Crc[27]; always @ (posedge Clk or posedge Reset) begin if (Reset) Crc <= 32'hffffffff; else if(Initialize) Crc <= 32'hffffffff; else Crc <= CrcNext; end assign CrcError = Crc[31:0] != 32'hc704dd7b; // CRC not equal to magic number endmodule
6.605847
module provided full functions `include "common.v" module EthernetModule(reset, clk_10K, ff_clk, ff_en_source, ff_en_sink, ff_data_source, ff_data_sink, //ff_clk should be a 270.33KHz clock phy_rxd, phy_rxen, phy_rxclk, phy_rxer, phy_txd, phy_txen, phy_txclk, phy_txer, phy_reset, phy_col, phy_linksts, phy_crs, test1, test2, test3, test4 ); input reset, clk_10K, ff_clk; output phy_reset, test1, test2, test3, test4; input ff_en_sink, ff_data_sink; //sink is used to receive data from the demodulate module output ff_en_source, ff_data_source;//source is used to provide the modulation module with data get from ethernet input[3:0] phy_rxd; //MII interface for the phy chip input phy_rxclk, phy_rxer; output[3:0] phy_txd; output phy_txer, phy_txen; //declare them as inout port because when powerup reset, they act as output pins to config DM9161 //after reset, phy_txclk and phy_rxen must be input ports inout phy_txclk, phy_col, phy_rxen, phy_linksts, phy_crs; wire out_en; wire rxen_in, txclk_in; `ifdef frameIDfromRx wire[23:0] frameid; //share the frameid between TxModule and RxModule `endif wire empty, start; InitModule initModule_inst(.init_clk(clk_10K), .reset(reset), .phy_reset(phy_reset), .out_en(out_en)); tri_state tri_state_inst1(.d_in(txclk_in ), .d_out(1'b0), .out_en(out_en), .ioport(phy_txclk)); tri_state tri_state_inst2(.d_in( ), .d_out(1'b0), .out_en(out_en), .ioport(phy_col)); tri_state tri_state_inst3(.d_in(rxen_in ), .d_out(1'b0), .out_en(out_en), .ioport(phy_rxen)); tri_state tri_state_inst4(.d_in( ), .d_out(1'b0), .out_en(out_en), .ioport(phy_linksts)); tri_state tri_state_inst5(.d_in( ), .d_out(1'b1), .out_en(out_en), .ioport(phy_crs)); TxModule TxModule_inst(.reset(out_en), .phy_txd(phy_txd), .phy_txen(phy_txen), .phy_txclk(txclk_in), .phy_txer(phy_txer), .ff_clk(ff_clk), .ff_en(ff_en_sink), .ff_data(ff_data_sink), `ifdef frameIDfromRx .frameid(frameid), `endif .start(start), .test1(), .test2(), .test3(), .test4()); //.test1(test1), .test2(test2), .test3(test3), .test4(test4)); RxModule RxModule_inst(.phy_rxd(phy_rxd), .phy_rxen(rxen_in), .phy_rxclk(phy_rxclk), .phy_rxer(phy_rxer), .ff_clk(ff_clk), .ff_data(ff_data_source), .ff_en(ff_en_source), `ifdef frameIDfromRx .frameid(frameid), `endif .start(start), //.test1(), .test2(), .test3(), .test4()); .test1(test1), .test2(test2), .test3(test3), .test4(test4)); endmodule
7.003451
module y86_seq ( input clk, input rst, output [31:0] bus_A, input [31:0] bus_in, output [31:0] bus_out, output bus_WE, bus_RE, output [7:0] current_opcode ); reg [5:1] full; wire [4:0] ue = {full[4:1], full[5]}; always @(posedge clk) begin if (rst) full <= 'b010000; else full <= {ue[4], ue[3], ue[2], ue[1], ue[0]}; end reg [31:0] IR; always @(posedge clk) if (ue[0]) IR <= '1; reg [31:0] IP, A, B; wire [31:0] Aop, Bop; wire [7:0] opcode = IR[7:0]; wire [1:0] mod = IR[15:14]; reg ZF; wire load = ((opcode == 'b010001011) && (mod == 1)); wire move = ((opcode == 'b010001001) && (mod == 3)); wire store = ((opcode == 'b010001001) && (mod == 1)); wire memory = (load || store); wire add = (opcode == 'b01); wire sub = (opcode == 'b0101001); wire halt = (opcode == 'b011110100); wire aluop = (add || sub); wire jnez = (opcode == 'b01110101); wire [4:0] RD = IR[10:8]; wire [4:0] RS = IR[13:11]; wire [4:0] Aad = (memory ? 6 : RD), Bad = RS; wire [31:0] distance = {{24{IR[15]}}, IR[15:8]}; wire [31:0] displacement = {{24{IR[23]}}, IR[23:16]}; wire btaken = (jnez && (!ZF)); wire [1:0] length = (memory ? 3 : (((aluop || move) || jnez) ? 2 : 1)); always @(posedge clk) if (rst) IP <= 0; else if (ue[1]) begin A <= Aop; B <= Bop; if ((!halt)) begin IP <= ((IP + length) + (btaken ? distance : 0)); end else begin $finish; end end reg [31:0] MAR, MDRw, C; wire [31:0] ALU_op2 = (memory ? displacement : (sub ? (~B) : B)); wire [31:0] ALUout = ((A + ALU_op2) + sub); always @(posedge clk) if (rst) ZF = 0; else if (ue[2]) begin MAR <= ALUout; C <= (move ? B : ALUout); MDRw <= B; if (aluop) ZF <= (ALUout == 0); end reg [31:0] MDRr; always @(posedge clk) if ((ue[3] && load)) MDRr <= bus_in; assign bus_A = (ue[3] ? MAR : (ue[0] ? IP : 0)); assign bus_RE = (ue[0] || (ue[3] && load)); reg [31:0] R[7:0]; assign Aop = R[Aad]; assign Bop = R[Bad]; assign bus_WE = (ue[3] && store); assign bus_out = MDRw; always @(posedge clk) if (rst) begin R[0] <= 0; R[1] <= 0; R[2] <= 0; R[3] <= 0; R[4] <= 0; R[5] <= 0; R[6] <= 0; R[7] <= 0; end else if (ue[4]) if (((aluop || move) || load)) if (load) R[RS] <= MDRr; else R[RD] <= C; assign current_opcode = opcode; endmodule
6.868788
module top_module ( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right, output walk_left, output walk_right ); // parameter LEFT = 0, RIGHT = 1; reg state, next_state; always @(*) begin // State transition logic case (state) LEFT: next_state = bump_left ? RIGHT : LEFT; RIGHT: next_state = bump_right ? LEFT : RIGHT; endcase end always @(posedge clk, posedge areset) begin // State flip-flops with asynchronous reset if (areset) begin state <= LEFT; end else begin state <= next_state; end end // Output logic assign walk_left = (state == LEFT); assign walk_right = (state == RIGHT); endmodule
7.203305
module top_module ( input clk, input L, input r_in, input q_in, output reg Q ); always @(posedge clk) begin case (L) 1'b0: Q <= q_in; 1'b1: Q <= r_in; endcase end endmodule
7.203305
module top_module ( input x, input y, output z ); assign z = ~(x ^ y); endmodule
7.203305
module updown_counter ( input [1:0] SW, output [7:0] LED, input CLK100MHZ ); make_clock_1hz gate0 ( CLK100MHZ, clk_1hz ); implement_tic_tock_fsm gate1 ( clk_1hz, SW, LED ); endmodule
7.294753
module write_to_7seg ( input CLK100MHZ, output [7:0] AN, output CA, CB, CC, CD, CE, CF, CG, DP ); wire [7:0] CAs; assign CA = CAs[7]; assign CB = CAs[6]; assign CC = CAs[5]; assign CD = CAs[4]; assign CE = CAs[3]; assign CF = CAs[2]; assign CG = CAs[1]; assign DP = CAs[0]; wire outgoing_CLK1KHZ; create_1KHZ_clock gate2 ( CLK100MHZ, outgoing_CLK1KHZ ); // Note, if you run this with the 100MHZ clock, the display is messed up. // Anode PNP transistors (~35+ns to switch?) might not be fast enough to keep up? write_17 gate1 ( outgoing_CLK1KHZ, AN, CAs ); // write_17 gate1 (CLK100MHZ,AN,CAs); endmodule
6.670833
module module teste; reg clk, reset, x; wire e01; exe01 exe1 ( e01, x, clk, reset ); initial begin $display("Andre Sulivam 391998"); $display("Guia 11 Ex:01\n"); $display ( "Time X Ex01" ); // initial values clk = 1; reset = 0; x = 0; // input signal changing #5 reset = 1; #10 x = 1; #10 x = 0; #10 x = 0; #10 x = 1; #10 x = 0; #10 x = 1; #10 x = 0; #10 x = 1; #30 $finish; end // initial always #5 clk = ~clk; always @( posedge clk ) begin $display ( "%4d %4b %4b", $time, x, e01 ); end // always at positive edge clocking changing endmodule
8.25634
module test_dim_LED ( input CLK100MHZ, input [3:0] SW, output [1:0] LED ); assign LED[0] = 1'b1; dim_LED gate0 ( CLK100MHZ, LED[1], SW[3:0] ); endmodule
6.913953
module implement_clocks( input CLK100MHZ, output [7:9] JA, output [2:0] LED, ); wire CLK_100HZ; // the brigntnesses on these two pins should differ assign LED[0] = 1'b1; assign LED[1] = CLK_50MHZ; assign LED[2] = CLK_1kHZ; // sending oth clocks to the PMOD pins on the lower JA header assign JA[7] = CLK_50MHZ; assign JA[8] = CLK_1kHZ; assign JA[9] = 1'b1; clk_50MHz_20ns gate0(CLK100MHZ, CLK_50MHZ); clk_1kHz_ims gate1(CLK100MHZ, CLK_1kHZ); endmodule
6.959204
module clk_1kHz_1ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); reg [16:0] ctr = 0; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 99_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.884424
module clk_100Hz_10ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); reg [19:0] ctr = 0; always @(posedge incoming_CLK100MHZ) begin if (ctr == 499_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 999_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
7.109824
module clk_10Hz_100ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 10HZ clock from a 100MHZ clock // 10HZ clock has a period of 0.1 second = 100ms // 100MHz / 10Hz => (100 * (1000) * (1000)) / 10 = 10,000,000 cycles // log2(10,000,000) = 23.2, so 24 bits needed for counter reg [23:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 4999999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 9999999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.873933
module clk_1Hz_1000ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 1HZ clock from a 100MHZ clock // 1HZ clock has a period of 1 second = 1000ms // 100MHz is 100,000,000 cycles // log2(10,0000,000) = 26.6, so 27 bits needed for counter reg [26:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 99_999_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.830282
modules that implement clocks at different speeds. Sample implementation is given at the top of the module. Assumed: incoming clock is 100MHz on a Digilent Basys3 or Nexys4DDR board Nathan Moore, 2021-11-16 */ //module implement_clocks( // input CLK100MHZ, // output [7:9] JA, // output [2:0] LED, // ); // wire CLK_100HZ; // // the brigntnesses on these two pins should differ // assign LED[0] = 1'b1; // assign LED[1] = CLK_50MHZ; // assign LED[2] = CLK_1kHZ; // // sending oth clocks to the PMOD pins on the lower JA header // assign JA[7] = CLK_50MHZ; // assign JA[8] = CLK_1kHZ; // assign JA[9] = 1'b1; // clk_50MHz_20ns gate0(CLK100MHZ, CLK_50MHZ); // clk_1kHz_ims gate1(CLK100MHZ, CLK_1kHZ); //endmodule
7.670757
module clk_1kHz_1ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // 100MHZ is 10ns cycles. // I want 1kHz output, 1ms cycles // 1ms = 1_000 us = 1_000_000 ns, so # of cycles needed is // 1_000_000 ns / 10 ns = 100k cycles // 2^17 = 131072 reg [16:0] ctr = 0; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999) begin outgoing_CLK <= 1'b0; ctr <= ctr + 1; end else if (ctr == 99_999) begin outgoing_CLK <= 1'b1; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.884424
module clk_100Hz_10ms( // input incoming_CLK100MHZ, // output reg outgoing_CLK // ); // always @ (posedge incoming_CLK100MHZ) begin // end //endmodule
7.109824
module clk_10Hz_100ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 10HZ clock from a 100MHZ clock // 10HZ clock has a period of 0.1 second = 100ms // 100MHz / 10Hz => (100 * (1000) * (1000)) / 10 = 10,000,000 cycles // log2(10,000,000) = 23.2, so 24 bits needed for counter reg [23:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 4999999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 9999999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.873933
module clk_1Hz_1000ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 1HZ clock from a 100MHZ clock // 1HZ clock has a period of 1 second = 1000ms // 100MHz / 1Hz => (100 * (1000) * (1000)) / 1 = 100_000_000 cycles // log2(100_000_000) = 26.5, so 27 bits needed for counter reg [26:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999_999) begin ctr <= ctr + 1; outgoing_CLK <= 1'b0; end else if (ctr == 99_999_999) begin ctr <= 0; outgoing_CLK <= 1'b1; end else begin ctr <= ctr + 1; end end endmodule
6.830282
module module implement_count_up_and_display( input CLK100MHZ, output [8:0] LED, output [7:0] AN, output CA,CB,CC,CD,CE,CF,CG,DP ); // set up the 1HZ clock wire CLK_1HZ; clk_1Hz_1000ms gate1( CLK100MHZ, CLK_1HZ); // set up a counter wire [7:0] sum; count_ticks gate2( CLK_1HZ, sum[7:0]); assign LED[7:0] = sum[7:0]; assign LED[8] = CLK_1HZ; // dim the 7-segs with a kHz clock clk_1kHz_1ms gate4( CLK100MHZ,CLK_1kHz); // set up the display assign AN[7:1] = 8'b1111_110; // full brightness assign AN[0] = CLK_1kHz; // 50% power assign DP = 1'b1; generate_7seg_bits gate3(sum[3], sum[2], sum[1], sum[0], CA,CB,CC,CD,CE,CF,CG); endmodule
6.550435
module implement_clocks( // input CLK100MHZ, // output [7:9] JA, // output [2:0] LED, // ); // wire CLK_100HZ; // // the brigntnesses on these two pins should differ // assign LED[0] = 1'b1; // assign LED[1] = CLK_50MHZ; // assign LED[2] = CLK_1kHZ; // // sending oth clocks to the PMOD pins on the lower JA header // assign JA[7] = CLK_50MHZ; // assign JA[8] = CLK_1kHZ; // assign JA[9] = 1'b1; // clk_50MHz_20ns gate0(CLK100MHZ, CLK_50MHZ); // clk_1kHz_ims gate1(CLK100MHZ, CLK_1kHZ); //endmodule
6.959204
module clk_2kHz_500us ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 2kHZ clock from a 100MHZ clock // 2kHz clock has a period of 500us = 500_000ns // 100MHz has period of 10ns // need log2(500_000ns/10ns = 50_000 cycles) = 15.6 so 16 bits reg [15:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 24_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 49_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.563842
module clk_1kHz_1ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 1000 Hz clock from a 100 MHz clock // 1000 Hz clock has a period of 0.001 seconds, which is equal to 1ms // 100 MHz / 1000 Hz = 100 * 10^6 / 1000 = 100,000 cycles // log_2(100,000) = 16.61, so 17 bits are needed for the counter reg [16:0] ctr = 0; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 99_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.884424
module clk_100Hz_10ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 100 Hz clock from a 100 MHz clock // 100 Hz clock has a period of 0.01 seconds, which is equal to 10ms // 100 MHz / 100 Hz = 100 * 10^6 / 100 = 1,000,000 cycles // log_2(1,000,000) = 19.93, so 20 bits are needed for the counter reg [19:0] ctr = 0; always @(posedge incoming_CLK100MHZ) begin if (ctr == 499_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 999_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
7.109824
module clk_10Hz_100ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 10HZ clock from a 100MHZ clock // 10HZ clock has a period of 0.1 second = 100ms // 100MHz / 10Hz => (100 * (1000) * (1000)) / 10 = 10,000,000 cycles // log2(10,000,000) = 23.2, so 24 bits needed for counter reg [23:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 4999999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 9999999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.873933
module clk_1Hz_1000ms ( input incoming_CLK100MHZ, output reg outgoing_CLK ); // creates 1HZ clock from a 100MHZ clock // 1HZ clock has a period of 1 second = 1000ms // 100MHz is 100,000,000 cycles // log2(10,0000,000) = 26.6, so 27 bits needed for counter reg [26:0] ctr; always @(posedge incoming_CLK100MHZ) begin if (ctr == 49_999_999) begin outgoing_CLK <= 1'b1; ctr <= ctr + 1; end else if (ctr == 99_999_999) begin outgoing_CLK <= 1'b0; ctr <= 0; end else begin ctr <= ctr + 1; end end endmodule
6.830282
module module implement_count_up_and_display( input CLK100MHZ, output [8:0] LED, output [7:0] AN, output CA,CB,CC,CD,CE,CF,CG,DP ); // set up the 1HZ clock wire CLK_1HZ; clk_1Hz_1000ms gate1( CLK100MHZ, CLK_1HZ); // set up a counter wire [7:0] sum; count_ticks gate2( CLK_1HZ, sum[7:0]); assign LED[7:0] = sum[7:0]; assign LED[8] = CLK_1HZ; // dim the 7-segs with a kHz clock wire CLK_1kHz; clk_1kHz_1ms gate4( CLK100MHZ,CLK_1kHz); // set up the display assign AN[7:2] = 8'b1111_11; assign AN[0] = ~CLK_1kHz; // remember, ACTIVE LOW assign AN[1] = CLK_1kHz; assign DP = 1'b1; wire CA0,CB0,CC0,CD0,CE0,CF0,CG0, CA1,CB1,CC1,CD1,CE1,CF1,CG1; // split the binary number via hex representation generate_7seg_bits digit0(sum[3], sum[2], sum[1], sum[0], CA0,CB0,CC0,CD0,CE0,CF0,CG0); generate_7seg_bits digit1(sum[7], sum[6], sum[5], sum[4], CA1,CB1,CC1,CD1,CE1,CF1,CG1); // implicit multiplexer assign CA = CLK_1kHz & CA0 | ~ CLK_1kHz & CA1; assign CB = CLK_1kHz & CB0 | ~ CLK_1kHz & CB1; assign CC = CLK_1kHz & CC0 | ~ CLK_1kHz & CC1; assign CD = CLK_1kHz & CD0 | ~ CLK_1kHz & CD1; assign CE = CLK_1kHz & CE0 | ~ CLK_1kHz & CE1; assign CF = CLK_1kHz & CF0 | ~ CLK_1kHz & CF1; assign CG = CLK_1kHz & CG0 | ~ CLK_1kHz & CG1; endmodule
6.550435
module module implement_count_up_and_display( input CLK100MHZ, input BTNL, // left button on Nexys4DDR input BTNR, // right button output [8:0] LED, output [7:0] AN, output CA,CB,CC,CD,CE,CF,CG,DP ); // set up the 1HZ clock wire CLK_1HZ; clk_1Hz_1000ms gate1( CLK100MHZ, CLK_1HZ); // set up a counter wire [31:0] sum; wire button, clear; assign button = BTNL; assign clear = BTNR; count_button_push gate2( CLK_1KHZ, button, clear, sum[31:0]); assign LED[7:0] = sum[7:0]; assign LED[8] = CLK_1HZ; // dim the 7-segs with a kHz clock wire CLK_1kHz; clk_1kHz_1ms gate4( CLK100MHZ,CLK_1kHz); wire CLK_2kHz; clk_2kHz_500us gate5( CLK100MHZ,CLK_2kHz); wire CLK_4kHz; clk_4kHz_250us gate6( CLK100MHZ,CLK_4kHz); // set up the display wire [7:0] hot; assign hot[0] = ( ~CLK_1kHz & ~CLK_2kHz & ~CLK_4kHz); // remember, ACTIVE LOW assign hot[1] = ( ~CLK_1kHz & ~CLK_2kHz & CLK_4kHz); assign hot[2] = ( ~CLK_1kHz & CLK_2kHz & ~CLK_4kHz); assign hot[3] = ( ~CLK_1kHz & CLK_2kHz & CLK_4kHz); assign hot[4] = ( CLK_1kHz & ~CLK_2kHz & ~CLK_4kHz); assign hot[5] = ( CLK_1kHz & ~CLK_2kHz & CLK_4kHz); assign hot[6] = ( CLK_1kHz & CLK_2kHz & ~CLK_4kHz); assign hot[7] = ( CLK_1kHz & CLK_2kHz & CLK_4kHz); assign AN[7:0] = ~ hot[7:0]; // remember, ACTIVE LOW assign DP = 1'b1; wire CA0,CB0,CC0,CD0,CE0,CF0,CG0, CA1,CB1,CC1,CD1,CE1,CF1,CG1; wire CA2,CB2,CC2,CD2,CE2,CF2,CG2, CA3,CB3,CC3,CD3,CE3,CF3,CG3; wire CA4,CB4,CC4,CD4,CE4,CF4,CG4, CA5,CB5,CC5,CD5,CE5,CF5,CG5; wire CA6,CB6,CC6,CD6,CE6,CF6,CG6, CA7,CB7,CC7,CD7,CE7,CF7,CG7; // split the binary number via hex representation generate_7seg_bits digit0( sum[3], sum[2], sum[1], sum[0], CA0,CB0,CC0,CD0,CE0,CF0,CG0); generate_7seg_bits digit1( sum[7], sum[6], sum[5], sum[4], CA1,CB1,CC1,CD1,CE1,CF1,CG1); generate_7seg_bits digit2(sum[11], sum[10], sum[9], sum[8], CA2,CB2,CC2,CD2,CE2,CF2,CG2); generate_7seg_bits digit3(sum[15], sum[14], sum[13], sum[12], CA3,CB3,CC3,CD3,CE3,CF3,CG3); generate_7seg_bits digit4(sum[19], sum[18], sum[17], sum[16], CA4,CB4,CC4,CD4,CE4,CF4,CG4); generate_7seg_bits digit5(sum[23], sum[22], sum[21], sum[20], CA5,CB5,CC5,CD5,CE5,CF5,CG5); generate_7seg_bits digit6(sum[27], sum[26], sum[25], sum[24], CA6,CB6,CC6,CD6,CE6,CF6,CG6); generate_7seg_bits digit7(sum[31], sum[30], sum[29], sum[28], CA7,CB7,CC7,CD7,CE7,CF7,CG7); // implicit multiplexer assign CA = hot[0] & CA0 | hot[1] & CA1 | hot[2] & CA2 | hot[3] & CA3 | hot[4] & CA4 | hot[5] & CA5 | hot[6] & CA6 | hot[7] & CA7; assign CB = hot[0] & CB0 | hot[1] & CB1 | hot[2] & CB2 | hot[3] & CB3 | hot[4] & CB4 | hot[5] & CB5 | hot[6] & CB6 | hot[7] & CB7; assign CC = hot[0] & CC0 | hot[1] & CC1 | hot[2] & CC2 | hot[3] & CC3 | hot[4] & CC4 | hot[5] & CC5 | hot[6] & CC6 | hot[7] & CC7; assign CD = hot[0] & CD0 | hot[1] & CD1 | hot[2] & CD2 | hot[3] & CD3 | hot[4] & CD4 | hot[5] & CD5 | hot[6] & CD6 | hot[7] & CD7; assign CE = hot[0] & CE0 | hot[1] & CE1 | hot[2] & CE2 | hot[3] & CE3 | hot[4] & CE4 | hot[5] & CE5 | hot[6] & CE6 | hot[7] & CE7; assign CF = hot[0] & CF0 | hot[1] & CF1 | hot[2] & CF2 | hot[3] & CF3 | hot[4] & CF4 | hot[5] & CF5 | hot[6] & CF6 | hot[7] & CF7; assign CG = hot[0] & CG0 | hot[1] & CG1 | hot[2] & CG2 | hot[3] & CG3 | hot[4] & CG4 | hot[5] & CG5 | hot[6] & CG6 | hot[7] & CG7; endmodule
6.550435
module count_button_push ( input CLK_IN, input button, input clear, output reg [31:0] sum_out ); always @(posedge CLK_IN) begin if (clear == 1) begin sum_out <= 0; end else if (button == 1 && clear == 0) begin sum_out <= sum_out + 32'b0000_0000_0000_0000_0000_0000_0000_0001; end end endmodule
6.736335
module top_module ( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right, input ground, output walk_left, output walk_right, output aaah ); parameter [1:0] LEFT = 2'b00, RIGHT = 2'b01, FALL_L = 2'b10, FALL_R = 2'b11; reg [1:0] state, nextstate; always @(*) begin case (state) LEFT: nextstate = (~ground) ? FALL_L : (bump_left ? RIGHT : LEFT); RIGHT: nextstate = (~ground) ? FALL_R : (bump_right ? LEFT : RIGHT); FALL_L: nextstate = (~ground) ? FALL_L : LEFT; FALL_R: nextstate = (~ground) ? FALL_R : RIGHT; endcase end always @(posedge clk, posedge areset) begin if (areset) state <= LEFT; else state <= nextstate; end assign walk_left = (state == LEFT); assign walk_right = (state == RIGHT); assign aaah = (state == FALL_L | state == FALL_R); endmodule
7.203305
module top_module ( input clk, input L, input r_in, input q_in, output reg Q ); always @(posedge clk) begin Q <= L ? r_in : q_in; end endmodule
7.203305