code stringlengths 35 6.69k | score float64 6.5 11.5 |
|---|---|
module clk_div (
clk,
clk_sel,
clk_out
);
input clk;
input [3:0] clk_sel;
output reg clk_out;
reg [15:0] counter;
reg [15:0] next_counter;
always @(posedge clk) begin
counter = next_counter;
end
always @* begin
next_counter = counter + 1;
case (clk_sel[3:0])
0: clk_out ... | 7.520262 |
module Complement_test;
reg [3:0] D;
wire [3:0] Q;
Complement u1 (
D,
Q
);
initial begin
#800 $finish;
end
initial begin
D = 4'b0000;
#100;
D = 4'b0001;
#50;
D = 4'b0010;
#50;
D = 4'b0011;
#50;
D = 4'b0100;
#50;
D = 4'b0101;
#50;
... | 6.605957 |
module MUX_2to1_32bit (
input [31:0] IN1,
input [31:0] IN2,
output [31:0] OP,
input CONTROL
);
reg [31:0] OP_REG;
always @(*) begin
case (CONTROL)
1'b0: OP_REG = IN1;
1'b1: OP_REG = IN2;
endcase
end
assign OP = OP_REG;
endmodule
| 8.487995 |
module MUX_4to1_32bit (
input [31:0] IN1,
input [31:0] IN2,
input [31:0] IN3,
input [31:0] IN4,
output [31:0] OP,
input [ 1:0] CONTROL
);
reg [31:0] OP_REG;
always @(*) begin
case (CONTROL)
2'b00: OP_REG = IN1;
2'b01: OP_REG = IN2;
2'b10: OP_REG = IN3;
2'b1... | 8.96532 |
module priority_decoder_1
(input wire [3:0] select,
output reg [2:0] priority // "priority" is not a keyword
);
// return bit number of highest bit set, or 7 if none set
always @(select) begin
casez (select) // synthesis full_case
4'b1???: priority = 4'h3;
4'b01??: priority = 4'h2;
4'b00... | 6.546663 |
module FA (
input A,
B,
Cin,
output S,
Cout
);
wire T0, T1, T2;
xor3 X1 (
A,
B,
Cin,
S
);
and2 A1 (
A,
B,
T0
);
and2 A2 (
B,
Cin,
T1
);
and2 A3 (
Cin,
A,
T2
);
or3 O1 (
T0,
T1,
T2,
... | 8.362615 |
module FS (
input Dec,
input A,
B,
Cin,
output Diff,
Cout
);
wire T0;
xor2 A4 (
B,
Dec,
T0
);
FA d (
A,
T0,
Cin,
Diff,
Cout
);
endmodule
| 7.689649 |
module FS_TB;
wire t_s, t_cout, t_diff, t_cout1;
reg t_a, t_b, t_cin, t_d;
FS I1 (
.Dec(t_d),
.A(t_a),
.B(t_b),
.Cin(t_cin),
.Diff(t_diff),
.Cout(t_cout1)
);
initial begin
$dumpfile("FS.vcd");
$dumpvars(0, FS_TB);
end
initial begin
$monitor(t_a, t_b, t_c... | 6.717657 |
module top_module (
input clk,
input reset, // Synchronous active-high reset
output [3:0] q
);
always @(posedge clk) begin
q <= (reset | q == 4'd9) ? 0 : q + 1;
end
endmodule
| 7.203305 |
module top_module (
input clk,
input [7:0] d,
output reg [7:0] q
);
// Because q is a vector, this creates multiple DFFs.
always @(posedge clk) q <= d;
endmodule
| 7.203305 |
module top_module (
input a,
b,
cin,
output cout,
sum
);
assign sum = a ^ b ^ cin;
assign cout = a & b | a & cin | b & cin;
endmodule
| 7.203305 |
module declaration syntax here:
module top_module(clk, reset, in, out);
input clk;
input reset; // Synchronous reset to state B
input in;
output out;//
reg out;
// Fill in state name declarations
reg present_state, next_state;
always @(posedge clk) begin
if (reset) begin ... | 6.89453 |
module top_module (
output out
);
assign out = 0;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
input c,
input d,
output out
);
assign out = ~a & ~b & ~c | ~a & ~c & ~d | a & ~b & ~c | b & c & d | a & ~b & c & d | ~a & c & ~d;
endmodule
| 7.203305 |
module top_module (
input [99:0] a,
b,
input sel,
output [99:0] out
);
assign out = sel ? b : a;
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) begin
q <= data;
end else begin
if (ena == 2'b01) begin
q <= {q[0], q[99:1]};
end else if (ena == 2'b10) begin
q <=... | 7.203305 |
module top_module (
input clk,
input load,
input [511:0] data,
output [511:0] q
);
always @(posedge clk) begin
if (load) q <= data;
else begin
q <= q ^ {q << 1} | ({~(q >> 1)} & q & {q << 1});
end
end
endmodule
| 7.203305 |
module top_module (
input [99:0] a,
b,
input sel,
output [99:0] out
);
assign out = (sel == 0 ? a : b);
endmodule
| 7.203305 |
module top_module (
input a,
b,
sel,
output out
);
always @(*) begin
if (sel == 1'b0) begin
out = a;
end else begin
out = b;
end
end
endmodule
| 7.203305 |
module top_module (
input in,
output out
);
assign out = in;
endmodule
| 7.203305 |
module top_module (
input a,
b,
c,
output w,
x,
y,
z
);
assign w = a;
assign x = b;
assign y = b;
assign z = c;
endmodule
| 7.203305 |
module top_module (
input in,
output out
);
assign out = ~in;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
output out
);
assign out = a & b;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
output out
);
assign out = ~(a | b);
endmodule
| 7.203305 |
module top_module (
input a,
input b,
output out
);
assign out = ~a ^ b;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
input c,
input d,
output out,
output out_n
);
wire in1, in2;
assign in1 = a & b;
assign in2 = c & d;
assign out = in1 | in2;
assign out_n = ~(in1 | in2);
endmodule
| 7.203305 |
module top_module (
input p1a,
p1b,
p1c,
p1d,
p1e,
p1f,
output p1y,
input p2a,
p2b,
p2c,
p2d,
output p2y
);
assign p1y = (p1a & p1b & p1c) | (p1d & p1e & p1f);
assign p2y = (p2a & p2b) | (p2d & p2c);
endmodule
| 7.203305 |
module top_module (
input wire [2:0] vec,
output wire [2:0] outv,
output wire o2,
output wire o1,
output wire o0
); // Module body starts after module declaration
assign outv = vec;
assign o2 = vec[2];
assign o1 = vec[1];
assign o0 = vec[0];
endmodule
| 7.203305 |
module top_module (
input wire [15:0] in,
output wire [ 7:0] out_hi,
output wire [ 7:0] out_lo
);
assign {out_hi, out_lo} = in;
endmodule
| 7.203305 |
module top_module (
input [31:0] in,
output [31:0] out
); //
assign {out[7:0], out[15:8], out[23:16], out[31:24]} = in;
endmodule
| 7.203305 |
module top_module (
input [2:0] a,
input [2:0] b,
output [2:0] out_or_bitwise,
output out_or_logical,
output [5:0] out_not
);
assign out_or_bitwise = a | b;
assign out_or_logical = a || b;
assign out_not[2:0] = ~a; // Part-select on left side is o.
assign out_not[5:3] = ~b; //Assigni... | 7.203305 |
module top_module (
input [3:0] in,
output out_and,
output out_or,
output out_xor
);
assign out_and = in[0] & in[1] & in[2] & in[3];
assign out_or = in[0] | in[1] | in[2] | in[3];
assign out_xor = in[0] ^ in[1] ^ in[2] ^ in[3];
endmodule
| 7.203305 |
module top_module (
input [4:0] a,
b,
c,
d,
e,
f,
output [7:0] w,
x,
y,
z
); //
assign w = {a[4:0], b[4:2]};
assign x = {b[1:0], c[4:0], d[4]};
assign y = {d[3:0], e[4:1]};
assign z = {e[0], f[4:0], 2'b11};
endmodule
| 7.203305 |
module top_module (
input [7:0] in,
output [7:0] out
);
assign out[7:0] = {in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]};
/*
// I know you're dying to know how to use a loop to do this:
// Create a combinational always block. This creates combinational logic that computes the same result
// ... | 7.203305 |
module top_module (
input [ 7:0] in,
output [31:0] out
); //
assign out = {{24{in[7]}}, {in}};
endmodule
| 7.203305 |
module top_module (
input a,
b,
c,
d,
e,
output [24:0] out
); //
wire [4:0] k = {a, b, c, d, e};
assign out[24:20] = ~{5{a}} ^ k;
assign out[19:15] = ~{5{b}} ^ k;
assign out[14:10] = ~{5{c}} ^ k;
assign out[9:5] = ~{5{d}} ^ k;
assign out[4:0] = ~{5{e}} ^ k;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
output out
);
// Create an instance of "mod_a" named "inst1", and connect ports by name:
mod_a inst1 (
.in1(a), // Port"in1"connects to wire "a"
.in2(b), // Port "in2" connects to wire "b"
.out(out) // Port "out" connects to wire "out"
... | 7.203305 |
module top_module (
input a,
input b,
input c,
input d,
output out1,
output out2
);
mod_a aa (
out1,
out2,
a,
b,
c,
d
);
endmodule
| 7.203305 |
module top_module (
input a,
input b,
input c,
input d,
output out1,
output out2
);
mod_a aaaa (
.out1(out1),
.out2(out2),
.in1 (a),
.in2 (b),
.in3 (c),
.in4 (d)
);
endmodule
| 7.203305 |
module top_module (
input clk,
input d,
output q
);
wire q1, q2;
my_dff d1 (
clk,
d,
q1
);
my_dff d2 (
clk,
q1,
q2
);
my_dff d3 (
clk,
q2,
q
);
endmodule
| 7.203305 |
module top_module (
input clk,
input [7:0] d,
input [1:0] sel,
output reg [7:0] q
);
wire [7:0] o1, o2, o3; // output of each my_dff8
// Instantiate three my_dff8s
my_dff8 d1 (
clk,
d,
o1
);
my_dff8 d2 (
clk,
o1,
o2
);
my_dff8 d3 (
clk,
o2... | 7.203305 |
module top_module (
input [31:0] a,
input [31:0] b,
output [31:0] sum
);
wire con1, con2;
add16 adder_1 (
a[15:0],
b[15:0],
0,
sum[15:0],
con1
);
add16 adder_2 (
a[31:16],
b[31:16],
con1,
sum[31:16],
con2
);
endmodule
| 7.203305 |
module top_module (
input [31:0] a,
input [31:0] b,
output [31:0] sum
); //
wire con1, con2;
add16 adder_1 (
a[15:0],
b[15:0],
0,
sum[15:0],
con1
);
add16 adder_2 (
a[31:16],
b[31:16],
con1,
sum[31:16],
con2
);
endmodule
| 7.203305 |
module add1 (
input a,
input b,
input cin,
output sum,
output cout
);
assign sum = a ^ b ^ cin;
assign cout = a & b | a & cin | b & cin;
endmodule
| 6.640243 |
module top_module (
input [31:0] a,
input [31:0] b,
output [31:0] sum
);
wire cout1, cout2a, cout2b;
wire [15:0] sum2a, sum2b;
add16 add1 (
a[15:0],
b[15:0],
0,
sum[15:0],
cout1
);
add16 add2a (
a[31:16],
b[31:16],
0,
sum2a,
cout2a
);... | 7.203305 |
module top_module (
input [31:0] a,
input [31:0] b,
input sub,
output [31:0] sum
);
wire cout, cout2;
wire [31:0] b_in;
assign b_in = b ^ {32{sub}};
add16 a1 (
a[15:0],
b_in[15:0],
sub,
sum[15:0],
cout
);
add16 a2 (
a[31:16],
b_in[31:16],
cout,... | 7.203305 |
module top_module (
input a,
input b,
output wire out_assign,
output reg out_alwaysblock
);
assign out_assign = a & b;
always @(*) out_alwaysblock = a & b;
endmodule
| 7.203305 |
module top_module (
input clk,
input a,
input b,
output wire out_assign,
output reg out_always_comb,
output reg out_always_ff
);
assign out_assign = a ^ b;
always @(*) out_always_comb = a ^ b;
always @(posedge clk) out_always_ff <= a ^ b;
endmodule
| 7.203305 |
module top_module (
input a,
input b,
input sel_b1,
input sel_b2,
output wire out_assign,
output reg out_always
);
assign out_assign = (sel_b1 & sel_b2) ? b : a;
always @(*) begin
if (sel_b1 & sel_b2) begin
out_always = b;
end else begin
out_always = a;
end
end
en... | 7.203305 |
module top_module (
input cpu_overheated,
output reg shut_off_computer,
input arrived,
input gas_tank_empty,
output reg keep_driving
); //
always @(*) begin
if (cpu_overheated) shut_off_computer = 1;
end
always @(*) begin
if (~arrived) keep_driving = ~gas_tank_empty;
... | 7.203305 |
module top_module (
input [2:0] sel,
input [3:0] data0,
input [3:0] data1,
input [3:0] data2,
input [3:0] data3,
input [3:0] data4,
input [3:0] data5,
output reg [3:0] out
); //
always @(*) begin // This is a combinational circuit
case (sel)
3'b000: out = data0;
3'b... | 7.203305 |
module top_module (
input [3:0] in,
output reg [1:0] pos
);
always @(*) begin
pos = (in[0] & 1) ? 2'd0 : (in[1] & 1) ? 2'd1 : (in[2] & 1) ? 2'd2 : (in[3] & 1) ? 2'd3 : 2'd0;
end
endmodule
| 7.203305 |
module top_module (
input [7:0] in,
output reg [2:0] pos
);
// casez treats bits that have the value z as don't-care in the comparison.
//Notice how there are certain inputs (e.g., 4'b1111) that will match more than one case item.
//The first match is chosen (so 4'b1111 matches the first item, out = 0,... | 7.203305 |
module top_module (
input [15:0] scancode,
output reg left,
output reg down,
output reg right,
output reg up
);
always @(*) begin
up = 1'b0;
down = 1'b0;
left = 1'b0;
right = 1'b0;
case (scancode)
16'he06b: left = 1'b1;
16'he072: down = 1'b1;
16'he074: right ... | 7.203305 |
module top_module (
input [7:0] a,
b,
c,
d,
output [7:0] min
); //
wire [7:0] min1 = (a < b) ? a : b;
wire [7:0] min2 = (c < d) ? c : d;
assign min = (min1 < min2) ? min1 : min2;
endmodule
| 7.203305 |
module top_module (
input [7:0] in,
output parity
);
assign parity = ^in;
endmodule
| 7.203305 |
module top_module (
input [99:0] in,
output out_and,
output out_or,
output out_xor
);
assign {out_and, out_or, out_xor} = {&in, |in, ^in};
endmodule
| 7.203305 |
module top_module (
input [99:0] in,
output [99:0] out
);
integer i;
always @(in) begin
for (i = 0; i < 100; i++) begin
out[i] = in[99-i];
end
end
endmodule
| 7.203305 |
module top_module (
input [254:0] in,
output reg [7:0] out
);
always @(*) begin // Combinational always block
out = 0;
for (int i = 0; i < 255; i++) out = out + in[i];
end
endmodule
| 7.203305 |
module top_module (
input [99:0] a,
b,
input cin,
output [99:0] cout,
output [99:0] sum
);
integer i;
always @(*) begin
sum[0] = a[0] ^ b[0] ^ cin;
cout[0] = a[0] & b[0] | cin & (a[0] | b[0]);
for (i = 1; i < 100; i++) begin
sum[i] = a[i] ^ b[i] ^ cout[i-1];
cout[i] = ... | 7.203305 |
module top_module (
input [399:0] a,
b,
input cin,
output cout,
output [399:0] sum
);
wire [99:0] cout_wires;
genvar i;
generate
bcd_fadd(
a[3:0], b[3:0], cin, cout_wires[0], sum[3:0]
);
for (i = 4; i < 400; i = i + 4) begin : bcd_adder_instances
bcd_fadd bcd_adder ... | 7.203305 |
module top_module (
input clk,
input areset, // Freshly brainwashed Lemmings walk left.
input bump_left,
input bump_right,
input ground,
output reg walk_left,
output reg walk_right,
output reg aaah
);
reg walk_temp[1:0];
initial begin
walk_left = 1;
walk_right = 0;
aaah ... | 7.203305 |
module top_module (
input a,
input b,
output out
);
mod_a(
.in1(a), .in2(b), .out(out)
);
endmodule
| 7.203305 |
module top_module (
input a,
input b,
output out
);
mod_a instance1 (
.in1(a),
.in2(b),
.out(out)
);
endmodule
| 7.203305 |
module DECODER (
sel,
out
);
input [3:0] sel;
output [15:0] out;
reg [15:0] out;
always @(sel) begin
case (sel)
4'h0: out = 16'h8000;
4'h1: out = 16'h4000;
4'h2: out = 16'h2000;
4'h3: out = 16'h1000;
4'h4: out = 16'h0800;
4'h5: out = 16'h0400;
4'h6: out = 16... | 6.800244 |
module MEMORY (
WE,
DataToWrite,
RegSel,
ReadData
);
input WE;
input [7:0] DataToWrite;
input [15:0] RegSel;
output [7:0] ReadData;
reg [7:0] ReadData;
reg [7:0] Mem[0:15];
always @(WE or DataToWrite or RegSel) begin
case (RegSel)
16'h8000: begin
if (WE) Mem[4'h0] = DataT... | 6.805941 |
module DATAPATH (
Num,
Key,
StoredValue
);
input [3:0] Num, Key;
output [7:0] StoredValue;
reg clock, EN, WE;
reg [3:0] sel;
wire [3:0] RegOut, RotOut1, RotOut2;
wire [ 7:0] Encrypt;
wire [15:0] Addr;
initial begin
#0 clock = 1'b1;
EN = 1'b1;
WE = 1'b1;
sel = 4'h8;
end
... | 6.685613 |
module top_module (
input [4:1] x,
output f
);
assign f = (~x[1]) & x[3] | (~x[2]) & (~x[4]) | x[1] & x[2] & x[3] & x[4];
endmodule
| 7.203305 |
module top_module (
input [5:0] y,
input w,
output Y1,
output Y3
);
assign Y1 = y[0] & w;
assign Y3 = y[1] & (~w) | y[2] & (~w) | y[4] & (~w) | y[5] & (~w);
endmodule
| 7.203305 |
module top_module (
input clk,
input reset, // synchronous reset
input w,
output z
);
parameter a = 3'b000, b = 3'b001, c = 3'b010, d = 3'b011, e = 3'b100, f = 3'b101;
reg [2:0] state, next_state;
always @(*) begin
case ({
state, w
})
{a, 1'b0} : next_state = a;
{a,... | 7.203305 |
module top_module (
input clk,
input resetn, // active-low synchronous reset
input [3:1] r, // request
output [3:1] g // grant
);
parameter a = 2'd0, b = 2'd1, c = 2'd2, d = 2'd3;
reg [1:0] state, next_state;
always @(*) begin
case (state)
a: begin
if (r[1]) next_state = b;
... | 7.203305 |
module top_module (
input clk,
input resetn, // active-low synchronous reset
input x,
input y,
output reg f,
output reg g
);
parameter A=4'd0, f1=4'd1, tmp0=4'd2, tmp1=4'd3, tmp2=4'd4, g1=4'd5, g1p=4'd6, tmp3=4'd7, g0p=4'd8;
reg [3:0] state, next_state;
always @(*) begin
case (state... | 7.203305 |
module top_module (
input clk,
input reset, // Synchronous reset
input x,
output z
);
parameter y0 = 3'd0, y1 = 3'd1, y2 = 3'd2, y3 = 3'd3, y4 = 3'd4;
reg [2:0] state, next_state;
always @(*) begin
case ({
state, x
})
{y0, 1'b0} : next_state = y0;
{y0, 1'b1} : next_s... | 7.203305 |
module top_module (
input clk,
input [2:0] y,
input x,
output Y0,
output z
);
reg [2:0] Y;
always @(*) begin
case ({
y, x
})
4'b0000: Y = 3'b000;
4'b0001: Y = 3'b001;
4'b0010: Y = 3'b001;
4'b0011: Y = 3'b100;
4'b0100: Y = 3'b010;
4'b0101: Y = 3... | 7.203305 |
module top_module (
input clk,
input reset, // Synchronous reset
input s,
input w,
output z
);
parameter a = 1'b0, b = 1'b1;
reg state, next_state;
reg [2:0] w3 = 0;
reg [1:0] count = 0;
always @(*) begin
case ({
state, s
})
{a, 1'b0} : next_state = a;
{a, 1... | 7.203305 |
module top_module (
input clk,
input w,
R,
E,
L,
output Q
);
wire out1, out2;
always @(posedge clk) begin
case (E)
1'b0: begin
out1 = Q;
end
1'b1: begin
out1 = w;
end
endcase
case (L)
1'b0: begin
Q = out1;
end
1'... | 7.203305 |
module top_module (
input [3:0] SW,
input [3:0] KEY,
output [3:0] LEDR
);
MUXDFF ins0 (
.clk(KEY[0]),
.E (KEY[1]),
.L (KEY[2]),
.w (LEDR[1]),
.R (SW[0]),
.Q (LEDR[0])
);
MUXDFF ins1 (
.clk(KEY[0]),
.E (KEY[1]),
.L (KEY[2]),
.w (LED... | 7.203305 |
module cpu //Do not change top module name or ports.
(
input clk,
input areset,
output [7:0] imem_addr, //Request instruction memory
input [7:0] imem_data, //Returns
output [7:0] tb_data //Testbench wiring.
);
//Data memory and testbench wiring. you may rename them if you like.
wire dmem_wr... | 7.390669 |
module RegisterFile (
input CLK,
input [1:0] ReadReg1,
input [1:0] ReadReg2,
input Write_enable,
input [1:0] WriteReg,
input [7:0] WriteData,
input areset,
output [7:0] ReadData1,
output [7:0] ReadData2
);
reg [7:0] registers[3:0];
initial begin
registers[0] <= 8'b00000000;... | 8.108491 |
module SignExtensionUnit (
input [5:0] in,
input Jump,
output reg [7:0] out
);
always @(*) begin
if (Jump == 1'b1) begin
out[5:0] <= in[5:0];
out[7:6] <= {2{in[5]}};
end else begin
out[1:0] <= in[1:0];
out[7:2] <= {6{in[1]}};
end
end
endmodule
| 6.562271 |
module ALU (
input [1:0] opcode,
input [7:0] ain,
bin,
output [7:0] result
);
wire b_l;
assign b_l = ~(bin) + 1;
assign result = (opcode==2'b01) ? (ain+bin) :
(opcode==2'b10) ? (ain-bin) :
(bin[7]==1) ? (ain - (b_l)) :
(ain+bin);
endmodule
| 7.960621 |
module TwoBitMUX (
input control,
input [1:0] in0,
input [1:0] in1,
output reg [1:0] out
);
always @(control or in0 or in1) begin
if (control == 0) begin
out <= in0;
end else begin
out <= in1;
end
end
endmodule
| 7.296648 |
module EightBitMUX (
input control,
input [7:0] in0,
input [7:0] in1,
output reg [7:0] out
);
always @(control or in0 or in1) begin
if (control == 0) begin
out <= in0;
end else begin
out <= in1;
end
end
endmodule
| 6.94892 |
module EightBitAdder (
input [7:0] a,
b,
output [7:0] s
);
assign s = a + b;
endmodule
| 7.369945 |
module MUX_2x1 (
sel,
in1,
in2,
out
);
input sel, in1, in2;
output out;
assign out = (~sel & in1) | (sel & in2);
endmodule
| 7.991836 |
module MUX_8x1 (
sel,
in,
out
);
input [2:0] sel;
input [7:0] in;
output out;
assign out = (sel[2] ? (sel[1] ? (sel[0] ? in[7] : in[6]) : (sel[0] ? in[5] : in[4])) : (sel[1] ? (sel[0] ? in[3] : in[2]) : (sel[0] ? in[1] : in[0])));
endmodule
| 6.799729 |
module COUNTER_3BIT (
Q,
clock,
clear
);
output [2:0] Q;
input clock, clear;
reg [2:0] Q;
initial Q = 3'b0;
always @(posedge clock or posedge clear) begin
if (clear) Q = 3'b0;
else Q = (Q + 1) % 8;
end
endmodule
| 6.61054 |
module DECODER (
EN,
A,
B
);
input EN;
input [2:0] A;
output [7:0] B;
reg [7:0] B;
always @(A) begin
if (EN == 0) B = 8'b00000000;
else begin
case (A)
3'b000: B = 8'b00000001;
3'b001: B = 8'b00000010;
3'b010: B = 8'b00000100;
3'b011: B = 8'b00001000;... | 6.800244 |
module MEMORY (
S,
G
);
input [2:0] S;
output [7:0] G;
reg [7:0] mem[0:7];
reg [7:0] G;
//Initialize the memory
initial begin
mem[0] = 8'b00000001; //2'h01;
mem[1] = 8'b00000011; //2'h03;
mem[2] = 8'b00000111; //2'h07;
mem[3] = 8'b00001111; //2'h0F;
mem[4] = 8'b00011111; /... | 6.805941 |
module TOP_MODULE (
clock,
clear,
S,
EN,
OUT
);
input clock, clear, EN;
input [2:0] S;
output OUT;
wire [2:0] Q;
wire [7:0] B, G, E;
MUX_8x1 M8 (
Q,
E,
OUT
);
MUX_ARRAY MA (
G,
B,
E
);
COUNTER_3BIT CNTR3 (
Q,
clock,
clear
... | 6.955484 |
module parity (
A,
B,
C,
I,
P
);
//Inputs
input A;
input B;
input C;
input I;
//Outputs
output P;
//Components
wire w1;
wire w2;
xor g1 (w1, A, B);
xor g2 (w2, w1, C);
xor g3 (P, I, w2);
endmodule
| 6.788563 |
module parity_tb;
//Inputs as registers
reg A;
reg B;
reg C;
reg I;
//Ouputs as wires
wire P;
//Initialiastion
parity uut (
A,
B,
C,
I,
P
);
initial begin
$dumpfile("2019AAPS0331H_tb.vcd");
$dumpvars(0, parity_tb);
// Uncomment a paritcular sequenc... | 7.477246 |
module top (
key, //按键输入
rst, //复位输入
led //led输出
);
input key, rst;
output reg led;
always @(key or rst)
if (!rst) //复位时led熄灭
led = 1;
else if (key == 0) led = ~led; //按键按下时led翻转
else led = led;
endmodule
| 6.85746 |
module LockedBox (
Key1,
Key2,
Key3,
Key4,
LED,
Button1,
Button2,
Seg_Led
);
//输入端口
//四个拨杆开关 用于输入密码
input Key1;
input Key2;
input Key3;
input Key4;
//两个按钮 用于确认两重密码正确性
input Button1;
input Button2;
//输出端口 两个LED灯 代表打开与否 一个七段数码管 代表是否解锁
output [1:0] LED;
output [8:0]... | 8.15301 |
module PGU20 (
a,
b,
p,
g
);
input [19:0] a, b;
output [19:0] p, g;
assign p = a ^ b;
assign g = a & b;
endmodule
| 7.929464 |
module D1_20bit (
in,
clk,
out
);
input [19:0] in;
input clk;
output reg [19:0] out;
always @(posedge clk) begin
out <= in;
end
endmodule
| 6.778767 |
module SU20 (
p,
cin,
c,
s
);
input [19:0] p;
input cin;
input [18:0] c;
output [19:0] s;
assign s = p ^ {c, cin};
endmodule
| 7.195935 |
module DD5_3bit (
in,
clk,
out
);
input [2:0] in;
input clk;
output reg [2:0] out;
reg [2:0] r_data[0:3];
always @(posedge clk) begin
r_data[0] <= in;
r_data[1] <= r_data[0];
r_data[2] <= r_data[1];
r_data[3] <= r_data[2];
out <= r_data[3];
end
endmodule
| 6.867734 |
module DD5_20bit (
in,
clk,
out
);
input [19:0] in;
input clk;
output reg [19:0] out;
reg [19:0] r_data[0:3];
always @(posedge clk) begin
r_data[0] <= in;
r_data[1] <= r_data[0];
r_data[2] <= r_data[1];
r_data[3] <= r_data[2];
out <= r_data[3];
end
endmodule
| 6.860049 |
module DD4_4bit (
in,
clk,
out
);
input [3:0] in;
input clk;
output reg [3:0] out;
reg [3:0] r_data[0:2];
always @(posedge clk) begin
r_data[0] <= in;
r_data[1] <= r_data[0];
r_data[2] <= r_data[1];
out <= r_data[2];
end
endmodule
| 6.796279 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.