Advertisement
STANAANDREY

aclab3 pb6

Oct 11th, 2023
1,386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module text2nibble (
  2.   input [7:0] i,
  3.   output reg[3:0] o
  4. );
  5.   always @(*)
  6.     if (48 <= i && i <= 57)
  7.         o = i - 48;
  8.     else
  9.         o = 15;
  10. endmodule
  11.  
  12. module text2nibble_tb;
  13.   reg [7:0] i;
  14.   wire [3:0] o;
  15.  
  16.   text2nibble text2nibble_i (.i(i), .o(o));
  17.  
  18.   integer k;
  19.   initial begin
  20.     $display("Time\ti\ti_chr\to");
  21.     $monitor("%0t\t%b\t%c\t%b(%d)", $time, i, i, o, o);
  22.     i = 0;
  23.     for (k = 1; k < 256; k = k + 1)
  24.       #10 i = k;
  25.   end
  26. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement