Vector 선언
type [upper:lower] vector_name;
Implict Nets - 암시적 Nets 방지하기
`default_nettype none
Packed Array
reg 타입 256-bit mem 변수를 총 8개 선언한 것
reg [7:0] mem [255:0]
Vector assign
wire [7:0] w;
와output [3:0] a
가 있을때assign w = a;
를 하면 8-bit w wire에 4-bit a가 할당된다고 보면된다.
bit수가 다를때 빈자리는 0으로 채워지고 모자란다면 잘려진다.
설명은 여기서 끝이고
이제 문제를 보자
Build a combinational circuit that splits an input half-word (16 bits, [15:0] ) into lower [7:0] and upper [15:8] bytes.
Combinational 회로를 만들어라 / half-word인 input을 lower 8bit upper 8bit으로 쪼개서 output해라 라는 문제이다.
간단히 in[15:8]
과 in[7:0]
으로 나누고 assign하면 된다.
`default_nettype none // Disable implicit nets. Reduces some types of bugs.
module top_module(
input wire [15:0] in,
output wire [7:0] out_hi,
output wire [7:0] out_lo
);
assign out_hi = in[15:8];
assign out_lo = in[ 7:0];
endmodule