Digital System Design-LAB #4: Sir Naveed Baloch Hamza Farooq 17-CP-18
Digital System Design-LAB #4: Sir Naveed Baloch Hamza Farooq 17-CP-18
Submitted To:
Sir Naveed Baloch
Submitted By:
Hamza Farooq
17-CP-18
-------------------------------------------------------------------
LAB TASKS
Question no 1: Practice a Verilog code for designing the RAM circuit of 1024 locations and
each location consists of 8-bits.
Answer:
Block Diagram
Verilog Code
Test Bench
Waveform
---------------------
Question no 2: Design a ROM of 2048 locations, in which each location consists of 16-bits.
using
$readmemb(“romdata.txt”,R,0,7);
Answer:
Block Diagram
Verilog Code
Test Bench
Waveform
---------------------
Question no 3: A 256x8 read only memory (ROM) is connected with a special
type of 8-bit register called program counter (PC). PC can operate in four possible
modes:
Mode of operation PC_ModeSel Description
Value in PC is
Increment 00
incremented by 1
Value in PC is
Decrement 01
decremented by 1
Load data (Branching A new 8-bit data can be
10
mode) loaded inside PC.
The current value of PC
Retain data 11
remains unchanged
In increment mode, the PC will update value by one at each positive edge of the clock. In
Branching mode, a value of 8-bit will be loaded from outside. After this the PC will
increment/decrement from this newly loaded value. The circuit diagram of problem is shown
below: Write a Verilog code and test bench for the above design.
Answer:
Block Diagram
Verilog Code
1. Program Counter:
2. ROM 256*8:
3. Final PC plus ROM:
Test Bench
Waveform
---------------------