Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8cc4dfc

Browse files
committed
Finding bugs in code solutions added
1 parent 435a9cf commit 8cc4dfc

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module top_module (input a, input b, input c, output out);//
2+
3+
wire temp;
4+
andgate inst1 ( temp, a, b, c, 1, 1 );
5+
//andgate inst1 ( .a(a), .b(b), .c(c), .d(1), .e(1), .out(temp) );
6+
assign out = ~ temp;
7+
8+
endmodule
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module top_module (
2+
input [1:0] sel,
3+
input [7:0] a,
4+
input [7:0] b,
5+
input [7:0] c,
6+
input [7:0] d,
7+
output [7:0] out ); //
8+
9+
wire [7:0] m0out, m1out;
10+
mux2 mux0 ( sel[0], a, b, m0out );
11+
mux2 mux1 ( sel[0], c, d, m1out );
12+
mux2 mux2 ( sel[1], m0out, m1out, out );
13+
14+
endmodule
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// synthesis verilog_input_version verilog_2001
2+
module top_module (
3+
input do_sub,
4+
input [7:0] a,
5+
input [7:0] b,
6+
output reg [7:0] out,
7+
output reg result_is_zero
8+
);//
9+
10+
always @(*) begin
11+
case (do_sub)
12+
0: out = a+b;
13+
1: out = a-b;
14+
endcase
15+
16+
if (~|out) //NOR reduction operator works here
17+
result_is_zero = 1;
18+
else //Latching problem
19+
result_is_zero = 0;
20+
end
21+
22+
endmodule
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module top_module (
2+
input [7:0] code,
3+
output reg [3:0] out,
4+
output reg valid
5+
);
6+
7+
// A combinational always block.
8+
always @(*) begin
9+
out = 0; // To avoid latches, give the outputs a default assignment
10+
valid = 1; // then override them in the case statement. This is less
11+
// code than assigning a value to every variable for every case.
12+
case (code)
13+
8'h45: out = 0;
14+
8'h16: out = 1;
15+
8'h1e: out = 2;
16+
8'h26: out = 3; // 8'd26 is 8'h1a
17+
8'h25: out = 4;
18+
8'h2e: out = 5;
19+
8'h36: out = 6;
20+
8'h3d: out = 7;
21+
8'h3e: out = 8;
22+
8'h46: out = 9;
23+
default: valid = 0;
24+
endcase
25+
end
26+
27+
endmodule

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /