SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
-

ASSIGNMENT-5
BY KANERIA DHAVAL
Verilog Code For Single Cycle Processor
DATAPATH WITH CONTROLLER

PC VERILOG CODE
module ProgramCounter
(
input [4:0]d_in,
input reset, clk,
output reg [4:0] d_out
);
always @(posedge clk)
if (reset)
d_out <= 5'b00000;
else
d_out <= d_in;
endmodule

AC VERILOG CODE
-

module Accumulator
(input [7:0] d_in,
input load, clk,
output reg [7:0] d_out
);
always @(posedge clk)
if (load)
d_out <= d_in;
initial
d_out=8'h00;
endmodule

ALU VERILOG CODE
module ALU
(
input [7:0]a, input [7:0]b,input [2:0]opcode,
output reg [7:0]alu_out
);
always @(opcode,a,b)
case(opcode)
3'b000:alu_out = a + b;
3'b001:alu_out = a - b;
3'b010:alu_out = a&b;
3'b011:alu_out = a|b;
3'b100:alu_out = ~b;
3'b101:alu_out = a^b;
3'b110:alu_out = a~^b;
default:alu_out = 0;
endcase
endmodule

ADDER VERILOG CODE
module CounterIncrement
(
input [4:0]a, input [4:0]b,
output[4:0] adder_out
);
assign adder_out = a + b;
endmodule
-

MUX-1 VERILOG CODE
module Mux2to1_6Bit
(
input [4:0] i0, i1,input sel,
output[4:0] mux_out
);
assign mux_out = sel ? i1 : i0;
endmodule

MUX-2 VERILOG CODE
module Mux2to1_8Bit
(
input [7:0]i0,i1,input sel,
output [7:0]mux_out
);
assign mux_out =sel?i1:i0;
endmodule

CONTROLLER VERILOG CODE
module Controller(
input [2:0] opcode,
output reg rd_mem,wr_mem,ac_src,ld_ac,pc_src,jmp_uncond);
always @(opcode)
begin
rd_mem = 1'b0;
wr_mem = 1'b0;
ac_src = 1'b0;
pc_src = 1'b0;
ld_ac = 1'b0;
jmp_uncond=1'b0;
case (opcode)
3'b000: //load accumulator from memory
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;
end
-

3'b001:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//SUBTRACT
end
3'b010:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//AND
end
3'b011:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//OR
end
3'b100:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//NOT
end
3'b101:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//XOR
end
3'b110:
begin
rd_mem = 1'b1;
wr_mem = 1'b0;
ld_ac = 1'b1;
ac_src = 1'b0;//XNOR
end
3'b111:
begin
-

rd_mem = 1'b0;
wr_mem = 1'b0;
ld_ac = 1'b0;
ac_src = 1'b0;
pc_src=1'b1;
jmp_uncond=1'b1;//JUMP
end
default:
begin
rd_mem = 1'b0;
wr_mem = 1'b0;
ac_src = 1'b0;
pc_src = 1'b0;
ld_ac = 1'b0;
end
endcase //end case
end //end always
endmodule

DATA MEMORY VERILOG CODE
module DataMemory (
input rd, wr,
input [4:0] abus,
input [7:0] in_dbus,
output reg [7:0] out_dbus);
reg [7:0] dm_array [0:31];
always @(rd,abus)
begin
if (rd)
out_dbus = dm_array [abus];
end
always @(wr,in_dbus) //always @(wr or abus or in_dbus)
begin
if (wr)
dm_array [abus] = in_dbus;
end
-

initial
begin
dm_array[0] = 8'h01;
dm_array[1] = 8'h02;
dm_array[2] = 8'h03;
dm_array[3] = 8'h04;
dm_array[4] = 8'h05;
end
endmodule

INSTRUCTION MEMORY VERILOG CODE
module InstructionMemory (input [4:0] abus, output reg [7:0] dbus);
reg [7:0] im_array [0:12];
always @(abus)
dbus = im_array [abus];
initial
begin
im_array[0]= 8'h00; // Initialize Accumulator with 0 and do addition with content of DataMemory at address 0.
im_array[1]= 8'h21; // Subtract content of accumulator with content of DataMemory at address 1.
im_array[2]= 8'h42; // Logical AND of accumulator with content of DataMemory at address 2.
im_array[3]= 8'h63; // Logical OR of accumulator with content of DataMemory at address 3.
im_array[4]= 8'h84; // Logical NOT of accumulator with content of DataMemory at address 4.
im_array[5]= 8'hA4; // Logical XOR of accumulator with content of DataMemory at address 4.
im_array[6]= 8'hC4; // Logical XNOR of accumulator with content of DataMemory at address 4.
im_array[7]= 8'hEA; // Unconditional Jump to 01010 address of Instruction memory.
im_array[10]= 8'h00; // Addition with content of DataMemory at address 0.
im_array[11]= 8'hE0; // Unconditional Jump to 00000 address of Instruction memory.
end
endmodule
-

DATAPATH MEMORY VERILOG CODE
module DataPath (
input reset,ld_ac, ac_src, pc_src, clk,
output [2:0] opcode,
output [4:0] im_abus,
input [7:0] im_dbus,
output [4:0] dm_abus,
output [7:0] dm_in_dbus,
input [7:0] dm_out_dbus,
output [7:0] ac_out,alu_out);
//wire [7:0] ac_out,alu_out,mux2_out;
wire [7:0]mux2_out;
wire [4:0] pc_out, adder_out,mux1_out;
ProgramCounter pc(.d_in(mux1_out),.reset(reset),.clk(clk),.d_out(pc_out)); //instantiation
of all module
CounterIncrement adder(.a(pc_out),.b(5'b00001),.adder_out(adder_out));
Mux2to1_6Bit
mux1(.i0(adder_out),.i1(im_dbus[4:0]),.sel(pc_src),.mux_out(mux1_out));
Accumulator
ac(.d_in(mux2_out),.load(ld_ac),.clk(clk),.d_out(ac_out));
ALU
alu(.a(ac_out),.b(dm_out_dbus),.opcode(opcode),.alu_out(alu_out));
Mux2to1_8Bit
mux2(.i0(alu_out),.i1(dm_out_dbus),.sel(ac_src),.mux_out(mux2_out));
assign im_abus = pc_out;
//assign im_abus = 6'b000000;
assign opcode = im_dbus [7:5];
assign dm_abus = im_dbus [4:0]; //abus for DataMemory.
assign dm_in_dbus=ac_out;
endmodule

SMPL. CPU MEMORY VERILOG CODE
module CPU( //The CPU
input clk,reset,
output rd_mem,wr_mem,
output [4:0] im_abus, input [7:0] im_dbus,
output [4:0] dm_abus, output [7:0] dm_in_dbus,
input [7:0] dm_out_dbus,
output [7:0] ac_out,alu_out,
output [2:0] opcode);
//wire [2:0] opcode;
-

wire ac_src,ld_ac, pc_src,jmp_uncond;
DataPath dpu
(.reset(reset),.ld_ac(ld_ac),.ac_src(ac_src),.pc_src(pc_src),.clk(clk),.opcode(opcode)
,.im_abus(im_abus),.im_dbus(im_dbus),.dm_abus(dm_abus),.dm_in_dbus(dm_in_dbus),.dm
_out_dbus(dm_out_dbus),.ac_out(ac_out),.alu_out(alu_out));//dj
Controller cu
(.opcode(opcode),.rd_mem(rd_mem),.wr_mem(wr_mem),.ac_src(ac_src),.ld_ac(ld_ac),
.pc_src(pc_src),.jmp_uncond(jmp_uncond));
endmodule

TEST BENCH SMPL. CPU MEMORY VERILOG CODE
module testBench;
reg clk;
reg reset;
wire [7:0] im_dbus;
wire [7:0] dm_out_dbus;

wire rd_mem;
wire wr_mem;
wire [4:0] im_abus;
wire [4:0] dm_abus;
wire [7:0] dm_in_dbus;
wire [7:0] ac_out,alu_out;
wire [2:0] opcode;

CPU uut (
.clk(clk),.reset(reset),.rd_mem(rd_mem),.wr_mem(wr_mem),
.im_abus(im_abus),.im_dbus(im_dbus),.dm_abus(dm_abus),
.dm_in_dbus(dm_in_dbus),.dm_out_dbus(dm_out_dbus),.ac_out(ac_out),.alu_out(alu
_out),.opcode(opcode));
InstructionMemory IM (.abus(im_abus),.dbus(im_dbus));
-

DataMemory DM
(.rd(rd_mem),.wr(wr_mem),.abus(dm_abus),.in_dbus(dm_in_dbus),.out_dbus(dm_out_dbus)
);
initial
begin
clk = 0;
reset = 1;//im_dbus =8'hxx;dm_out_dbus = 8'b00000000;
#20 reset = 1'b0;
#500 $finish;
end
always
#10 clk = ~clk;
Endmodule
RTL DIAGRAM
-

Insideview of RTL

RTL OF CPU
-

RTL OF DATAPATH

Technology map
-

TEST BENCH WAVE FORM :
Data memory :
Location

00

01

02

03

04

Data

01

02

03

04

05

1

2

3

4

5

6

7

8

9

21

42

63

84

A4

C4

EA

00

E0

FF

05

06

Instruction memory :
Location

0

Instruction 00

(* operation with accumulator with location in last 5 bit)
Ans (in acc in hex) 00 01

FF

03

07

FA

07

Weitere ähnliche Inhalte

Was ist angesagt?

Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
Ron Liu
 
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopyObstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
Elijah Barner
 

Was ist angesagt? (20)

System verilog important
System verilog importantSystem verilog important
System verilog important
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
VLSI Design Flow
VLSI Design FlowVLSI Design Flow
VLSI Design Flow
 
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopyObstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
Obstacle_Avoidance_Robot_Coruse_Project_ECET402_Mechatronics_FinalCopy
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginners
 
Verilog coding of demux 8 x1
Verilog coding of demux  8 x1Verilog coding of demux  8 x1
Verilog coding of demux 8 x1
 
7 8255
7 82557 8255
7 8255
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERMastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
 
structural modeling, hazards
structural modeling, hazardsstructural modeling, hazards
structural modeling, hazards
 
Encoder decoder
Encoder decoderEncoder decoder
Encoder decoder
 
ARM lab programs
ARM  lab programs  ARM  lab programs
ARM lab programs
 
Ch12 microprocessor interrupts
Ch12 microprocessor interruptsCh12 microprocessor interrupts
Ch12 microprocessor interrupts
 
Verilog
VerilogVerilog
Verilog
 
Advd lecture 7 logical effort
Advd   lecture 7 logical effortAdvd   lecture 7 logical effort
Advd lecture 7 logical effort
 
interrupts of 8051.pdf
interrupts of 8051.pdfinterrupts of 8051.pdf
interrupts of 8051.pdf
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programming
 

Andere mochten auch

Mips implementation
Mips implementationMips implementation
Mips implementation
hoang974
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
Waqar Jamil
 

Andere mochten auch (9)

Mips implementation
Mips implementationMips implementation
Mips implementation
 
06 mips-isa
06 mips-isa06 mips-isa
06 mips-isa
 
8 bit alu design
8 bit alu design8 bit alu design
8 bit alu design
 
Case study of digital camera
Case study of digital cameraCase study of digital camera
Case study of digital camera
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
 
Lec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processor
 
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 

Ähnlich wie 8 bit single cycle processor

망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
종인 전
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
SIGMATAX1
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
fisher.w.y
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
Jay Patel
 

Ähnlich wie 8 bit single cycle processor (20)

망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
 
0.my book draft chap 1
0.my book draft chap 10.my book draft chap 1
0.my book draft chap 1
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
2.1 ### uVision Project, (C) Keil Software .docx
2.1   ### uVision Project, (C) Keil Software    .docx2.1   ### uVision Project, (C) Keil Software    .docx
2.1 ### uVision Project, (C) Keil Software .docx
 
Der perfekte 12c trigger
Der perfekte 12c triggerDer perfekte 12c trigger
Der perfekte 12c trigger
 
An Example MIPS
An Example  MIPSAn Example  MIPS
An Example MIPS
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6
 
Joel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMDJoel Falcou, Boost.SIMD
Joel Falcou, Boost.SIMD
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
CUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" courseCUDA lab's slides of "parallel programming" course
CUDA lab's slides of "parallel programming" course
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 

Mehr von Dhaval Kaneria

Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
Dhaval Kaneria
 

Mehr von Dhaval Kaneria (19)

Swine flu
Swine flu Swine flu
Swine flu
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
 
Gpu with cuda architecture
Gpu with cuda architectureGpu with cuda architecture
Gpu with cuda architecture
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
HDMI
HDMIHDMI
HDMI
 
Hdmi
HdmiHdmi
Hdmi
 
open source hardware
open source hardwareopen source hardware
open source hardware
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Manage Xilinx ISE 14.5 licence for Windows 8 and 8.1
Manage Xilinx ISE 14.5 licence for Windows 8 and 8.1Manage Xilinx ISE 14.5 licence for Windows 8 and 8.1
Manage Xilinx ISE 14.5 licence for Windows 8 and 8.1
 
Paper on Optimized AES Algorithm Core Using FeedBack Architecture
Paper on Optimized AES Algorithm Core Using  FeedBack Architecture Paper on Optimized AES Algorithm Core Using  FeedBack Architecture
Paper on Optimized AES Algorithm Core Using FeedBack Architecture
 
PAPER ON MEMS TECHNOLOGY
PAPER ON MEMS TECHNOLOGYPAPER ON MEMS TECHNOLOGY
PAPER ON MEMS TECHNOLOGY
 
VIdeo Compression using sum of Absolute Difference
VIdeo Compression using sum of Absolute DifferenceVIdeo Compression using sum of Absolute Difference
VIdeo Compression using sum of Absolute Difference
 
Mems technology
Mems technologyMems technology
Mems technology
 
Network security
Network securityNetwork security
Network security
 
Token bus standard
Token bus standardToken bus standard
Token bus standard
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

8 bit single cycle processor

  • 1. - ASSIGNMENT-5 BY KANERIA DHAVAL Verilog Code For Single Cycle Processor DATAPATH WITH CONTROLLER PC VERILOG CODE module ProgramCounter ( input [4:0]d_in, input reset, clk, output reg [4:0] d_out ); always @(posedge clk) if (reset) d_out <= 5'b00000; else d_out <= d_in; endmodule AC VERILOG CODE
  • 2. - module Accumulator (input [7:0] d_in, input load, clk, output reg [7:0] d_out ); always @(posedge clk) if (load) d_out <= d_in; initial d_out=8'h00; endmodule ALU VERILOG CODE module ALU ( input [7:0]a, input [7:0]b,input [2:0]opcode, output reg [7:0]alu_out ); always @(opcode,a,b) case(opcode) 3'b000:alu_out = a + b; 3'b001:alu_out = a - b; 3'b010:alu_out = a&b; 3'b011:alu_out = a|b; 3'b100:alu_out = ~b; 3'b101:alu_out = a^b; 3'b110:alu_out = a~^b; default:alu_out = 0; endcase endmodule ADDER VERILOG CODE module CounterIncrement ( input [4:0]a, input [4:0]b, output[4:0] adder_out ); assign adder_out = a + b; endmodule
  • 3. - MUX-1 VERILOG CODE module Mux2to1_6Bit ( input [4:0] i0, i1,input sel, output[4:0] mux_out ); assign mux_out = sel ? i1 : i0; endmodule MUX-2 VERILOG CODE module Mux2to1_8Bit ( input [7:0]i0,i1,input sel, output [7:0]mux_out ); assign mux_out =sel?i1:i0; endmodule CONTROLLER VERILOG CODE module Controller( input [2:0] opcode, output reg rd_mem,wr_mem,ac_src,ld_ac,pc_src,jmp_uncond); always @(opcode) begin rd_mem = 1'b0; wr_mem = 1'b0; ac_src = 1'b0; pc_src = 1'b0; ld_ac = 1'b0; jmp_uncond=1'b0; case (opcode) 3'b000: //load accumulator from memory begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0; end
  • 4. - 3'b001: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//SUBTRACT end 3'b010: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//AND end 3'b011: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//OR end 3'b100: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//NOT end 3'b101: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//XOR end 3'b110: begin rd_mem = 1'b1; wr_mem = 1'b0; ld_ac = 1'b1; ac_src = 1'b0;//XNOR end 3'b111: begin
  • 5. - rd_mem = 1'b0; wr_mem = 1'b0; ld_ac = 1'b0; ac_src = 1'b0; pc_src=1'b1; jmp_uncond=1'b1;//JUMP end default: begin rd_mem = 1'b0; wr_mem = 1'b0; ac_src = 1'b0; pc_src = 1'b0; ld_ac = 1'b0; end endcase //end case end //end always endmodule DATA MEMORY VERILOG CODE module DataMemory ( input rd, wr, input [4:0] abus, input [7:0] in_dbus, output reg [7:0] out_dbus); reg [7:0] dm_array [0:31]; always @(rd,abus) begin if (rd) out_dbus = dm_array [abus]; end always @(wr,in_dbus) //always @(wr or abus or in_dbus) begin if (wr) dm_array [abus] = in_dbus; end
  • 6. - initial begin dm_array[0] = 8'h01; dm_array[1] = 8'h02; dm_array[2] = 8'h03; dm_array[3] = 8'h04; dm_array[4] = 8'h05; end endmodule INSTRUCTION MEMORY VERILOG CODE module InstructionMemory (input [4:0] abus, output reg [7:0] dbus); reg [7:0] im_array [0:12]; always @(abus) dbus = im_array [abus]; initial begin im_array[0]= 8'h00; // Initialize Accumulator with 0 and do addition with content of DataMemory at address 0. im_array[1]= 8'h21; // Subtract content of accumulator with content of DataMemory at address 1. im_array[2]= 8'h42; // Logical AND of accumulator with content of DataMemory at address 2. im_array[3]= 8'h63; // Logical OR of accumulator with content of DataMemory at address 3. im_array[4]= 8'h84; // Logical NOT of accumulator with content of DataMemory at address 4. im_array[5]= 8'hA4; // Logical XOR of accumulator with content of DataMemory at address 4. im_array[6]= 8'hC4; // Logical XNOR of accumulator with content of DataMemory at address 4. im_array[7]= 8'hEA; // Unconditional Jump to 01010 address of Instruction memory. im_array[10]= 8'h00; // Addition with content of DataMemory at address 0. im_array[11]= 8'hE0; // Unconditional Jump to 00000 address of Instruction memory. end endmodule
  • 7. - DATAPATH MEMORY VERILOG CODE module DataPath ( input reset,ld_ac, ac_src, pc_src, clk, output [2:0] opcode, output [4:0] im_abus, input [7:0] im_dbus, output [4:0] dm_abus, output [7:0] dm_in_dbus, input [7:0] dm_out_dbus, output [7:0] ac_out,alu_out); //wire [7:0] ac_out,alu_out,mux2_out; wire [7:0]mux2_out; wire [4:0] pc_out, adder_out,mux1_out; ProgramCounter pc(.d_in(mux1_out),.reset(reset),.clk(clk),.d_out(pc_out)); //instantiation of all module CounterIncrement adder(.a(pc_out),.b(5'b00001),.adder_out(adder_out)); Mux2to1_6Bit mux1(.i0(adder_out),.i1(im_dbus[4:0]),.sel(pc_src),.mux_out(mux1_out)); Accumulator ac(.d_in(mux2_out),.load(ld_ac),.clk(clk),.d_out(ac_out)); ALU alu(.a(ac_out),.b(dm_out_dbus),.opcode(opcode),.alu_out(alu_out)); Mux2to1_8Bit mux2(.i0(alu_out),.i1(dm_out_dbus),.sel(ac_src),.mux_out(mux2_out)); assign im_abus = pc_out; //assign im_abus = 6'b000000; assign opcode = im_dbus [7:5]; assign dm_abus = im_dbus [4:0]; //abus for DataMemory. assign dm_in_dbus=ac_out; endmodule SMPL. CPU MEMORY VERILOG CODE module CPU( //The CPU input clk,reset, output rd_mem,wr_mem, output [4:0] im_abus, input [7:0] im_dbus, output [4:0] dm_abus, output [7:0] dm_in_dbus, input [7:0] dm_out_dbus, output [7:0] ac_out,alu_out, output [2:0] opcode); //wire [2:0] opcode;
  • 8. - wire ac_src,ld_ac, pc_src,jmp_uncond; DataPath dpu (.reset(reset),.ld_ac(ld_ac),.ac_src(ac_src),.pc_src(pc_src),.clk(clk),.opcode(opcode) ,.im_abus(im_abus),.im_dbus(im_dbus),.dm_abus(dm_abus),.dm_in_dbus(dm_in_dbus),.dm _out_dbus(dm_out_dbus),.ac_out(ac_out),.alu_out(alu_out));//dj Controller cu (.opcode(opcode),.rd_mem(rd_mem),.wr_mem(wr_mem),.ac_src(ac_src),.ld_ac(ld_ac), .pc_src(pc_src),.jmp_uncond(jmp_uncond)); endmodule TEST BENCH SMPL. CPU MEMORY VERILOG CODE module testBench; reg clk; reg reset; wire [7:0] im_dbus; wire [7:0] dm_out_dbus; wire rd_mem; wire wr_mem; wire [4:0] im_abus; wire [4:0] dm_abus; wire [7:0] dm_in_dbus; wire [7:0] ac_out,alu_out; wire [2:0] opcode; CPU uut ( .clk(clk),.reset(reset),.rd_mem(rd_mem),.wr_mem(wr_mem), .im_abus(im_abus),.im_dbus(im_dbus),.dm_abus(dm_abus), .dm_in_dbus(dm_in_dbus),.dm_out_dbus(dm_out_dbus),.ac_out(ac_out),.alu_out(alu _out),.opcode(opcode)); InstructionMemory IM (.abus(im_abus),.dbus(im_dbus));
  • 9. - DataMemory DM (.rd(rd_mem),.wr(wr_mem),.abus(dm_abus),.in_dbus(dm_in_dbus),.out_dbus(dm_out_dbus) ); initial begin clk = 0; reset = 1;//im_dbus =8'hxx;dm_out_dbus = 8'b00000000; #20 reset = 1'b0; #500 $finish; end always #10 clk = ~clk; Endmodule RTL DIAGRAM
  • 12. - TEST BENCH WAVE FORM : Data memory : Location 00 01 02 03 04 Data 01 02 03 04 05 1 2 3 4 5 6 7 8 9 21 42 63 84 A4 C4 EA 00 E0 FF 05 06 Instruction memory : Location 0 Instruction 00 (* operation with accumulator with location in last 5 bit) Ans (in acc in hex) 00 01 FF 03 07 FA 07