Menu
Coddy logo textTech

Recap - Number Formats

Part of the Fundamentals section of Coddy's Verilog journey. Lesson 18 of 90.

challenge icon

Challenge

Complete the code by writing the correct values in the specified formats.

What to do:

  1. Set a to 8-bit binary for decimal 170 (10101010)
  2. Set b to 8-bit decimal for 255
  3. Set c to 16-bit hex for FF
  4. Set d to a 4-bit value where bit 2 is X (others 1)
  5. Set e to all bits Z (4 bits)

Try it yourself

module number_formats;
  wire [7:0] a, b;
  wire [15:0] c;
  wire [3:0] d, e;
  
  assign a = ______;   // 8-bit binary for 170
  assign b = ______;   // 8-bit decimal for 255
  assign c = ______;   // 16-bit hex for FF
  assign d = ______;   // 4-bit: bit 2 is X, others 1
  assign e = ______;   // 4-bit: all bits Z
  
  initial begin
    $display("a = %b", a);
    $display("b = %b", b);
    $display("c = %h", c);
    $display("d = %b", d);
    $display("e = %b", e);
    $finish;
  end
  
endmodule

All lessons in Fundamentals

Practice on your own: Online Verilog compiler