1 4-Integrating Peripherals in Embedded Systems (cont.)

Slides:



Advertisements
Similar presentations
//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
Advertisements

Traffic light contoller using FSM
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Verilog Modules for Common Digital Functions
Table 7.1 Verilog Operators.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Input/Output (I/O) Ports and Interfacing
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Latches and Flip-Flops Discussion D8.1 Section 13-9.
FSM examples.
Pulse-Width Modulated DAC
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Introduction to Verilog (Behavioral Modeling). Agenda Gate Delays and User-Defined Primitives Behavioral Modeling Design Examples Hands-on Practice.
LEDs 7-Segment Displays
Ring Counter Discussion 11.3 Example 32.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
ECE 265 – LECTURE 13 Interface to switches and LEDs 7/3/ ECE265.
Introduction to Verilog Multiplexers. Introduction to Verilog Verilog Hardware Description Language (Verilog HDL) released by Gateway Design Automation.
Lessons from last lab: 1.Many had the “# skipping” problem 2.Most assumed there was something wrong with their code 3.How does one check their code? 4.SIMULATE!!
D Flip-Flops in Verilog Discussion 10.3 Example 27.
Quad 2-to-1 Multiplexer Discussion D7.4 Example 7.
Digital Logic Review Discussion D8.7.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 8, 2007.
7-Segment Display DIO1 Board Verilog.
Digital Outputs 7-Segment Display
Embedded Systems Design 1 Lecture Set B Interfacing the MCS-51 to: –7 and 16 segment displays –a Multiplexed 7-Segment Display –a Keypad –an LCD.
Figure 1.1 The Altera UP 3 FPGA Development board
Verilog Digital System Design Z. Navabi, 2006
COE4OI5 Engineering Design Chapter 2: UP2/UP3 board.
1 4-Integrating Peripherals in Embedded Systems (cont.)
Input/Output Ports and Interfacing
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,
Assignment 7  參考 Verilog_Numbers_Displays.pdf ,並完成實驗。
Traffic Lights Discussion D8.3a. Recall Divide-by-8 Counter Use Q2, Q1, Q0 as inputs to a combinational circuit to produce an arbitrary waveform. s0 0.
Reaction Timer Project
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
1 Arithmetic, ALUs Lecture 9 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
COE4OI5 Engineering Design Chapter 1: The 15 minutes design.
Teaching Digital Logic courses with Altera Technology
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Introduction to the DE0 Board Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Computer Logic Design.
Vishwakarma government engineering college Prepare by. Hardik Jolapara( ) LCD Interfacing with ATmega16.
Figure Implementation of an FSM in a CPLD..
40106B Schmitt Trigger (A way of switch De-Bouncing)
DE2-115 Control Panel - Part I
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
4-Integrating Peripherals in Embedded Systems (cont.)
Lottery Speaker: Tsung-Yi Wu.
COMP211 Computer Logic Design Introduction to the DE2 Board
Pulse-Width Modulation (PWM)
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
Lab 1. Introduction to the DE2 Board
Lecture 4. Introduction to the DE2 Board
//HDL Example 7-1 // //Read and write operations of memory. //Memory size is 64 words of 4 bits each. module.
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

1 4-Integrating Peripherals in Embedded Systems (cont.)

2 Using LEDs and switches The DE2 board provides four pushbutton switches. Each of these switches is debounced using a Schmitt Trigger circuit. The four outputs called KEY0, …, KEY3 are connected directly to the Cyclone II FPGA. Each switch provides a high logic level (3.3 volts) when it is not pressed, and provides a low logic level (0 volts) when depressed. Since the pushbutton switches are debounced, they are appropriate for use as clock or reset inputs in a circuit.

3 Using LEDs and switches

4

5 There are also 18 toggle switches (sliders) on the DE2 board. These switches are not debounced, and are intended for use as level-sensitive data inputs to a circuit. When a switch is in the DOWN position (closest to the edge of the board) it provides a low logic level (0 volts) to the FPGA, and when the switch is in the UP position it provides a high logic level (3.3 volts).

6 Using LEDs and switches

7 There are 27 user-controllable LEDs on the DE2 board. Eighteen red LEDs are situated above the 18 toggle switches Eight green LEDs are found above the pushbutton switches (the 9th green LED is in the middle of the 7-segment displays). Each LED is driven directly by a pin on the Cyclone II FPGA; driving its associated pin to a high logic level turns the LED on, and driving the pin low turns it off.

8 Using LEDs and switches

9

10 Seven Segment Display The DE2 Board has eight 7-segment displays. These displays are arranged into two pairs and a group of four, with the intent of displaying numbers of various sizes. Applying a low logic level to a segment causes it to light up, and applying a high logic level turns it off.

11 LED_pio.v module led_red ( // inputs: address, chipselect, clk, reset_n, write_n, writedata, // outputs: out_port ); output [ 17: 0] out_port; input [ 1: 0] address; input chipselect; input clk; input reset_n; input write_n; input [ 17: 0] writedata; wire clk_en; reg [ 17: 0] data_out; wire [ 17: 0] out_port; assign clk_en = 1; clk or negedge reset_n) begin if (reset_n == 0) data_out <= 0; else if (chipselect && ~write_n && (address == 0)) data_out <= writedata[17 : 0]; end assign out_port = data_out; endmodule

12 Switch_pio.v module switch_pio ( // inputs: address, clk, in_port, reset_n, // outputs: readdata ) ; output [ 17: 0] readdata; input [ 1: 0] address; input clk; input [ 17: 0] in_port; input reset_n; wire clk_en; wire [ 17: 0] data_in; wire [ 17: 0] read_mux_out; reg [ 17: 0] readdata; assign clk_en = 1; //s1, which is an e_avalon_slave assign read_mux_out = {18 {(address == 0)}} & data_in; clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign data_in = in_port; endmodule

13 Button_pio.v (1) module button_pio ( // inputs: address, chipselect, clk, in_port, reset_n, write_n, writedata, // outputs: irq, readdata ); output irq; output [ 3: 0] readdata; input [ 1: 0] address; input chipselect; input clk; input [ 3: 0] in_port; input reset_n; input write_n; input [ 3: 0] writedata; wire clk_en; reg [ 3: 0] d1_data_in; reg [ 3: 0] d2_data_in; wire [ 3: 0] data_in; reg [ 3: 0] edge_capture; wire edge_capture_wr_strobe; wire [ 3: 0] edge_detect; wire irq; reg [ 3: 0] irq_mask; wire [ 3: 0] read_mux_out; reg [ 3: 0] readdata; assign clk_en = 1;

14 Button_pio.v (2) assign read_mux_out = ({4 {(address == 0)}} & data_in) | ({4 {(address == 2)}} & irq_mask) | ({4 {(address == 3)}} & edge_capture); clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign data_in = in_port; clk or negedge reset_n) begin if (reset_n == 0) irq_mask <= 0; else if (chipselect && ~write_n && (address == 2)) irq_mask <= writedata[3 : 0]; end assign irq = |(edge_capture & irq_mask); assign edge_capture_wr_strobe = chipselect && ~write_n && (address == 3); clk or negedge reset_n) begin if (reset_n == 0) edge_capture[0] <= 0; else if (clk_en) if (edge_capture_wr_strobe) edge_capture[0] <= 0; else if (edge_detect[0]) edge_capture[0] <= -1; end

15 Button_pio.v (3) clk or negedge reset_n) begin if (reset_n == 0) edge_capture[1] <= 0; else if (clk_en) if (edge_capture_wr_strobe) edge_capture[1] <= 0; else if (edge_detect[1]) edge_capture[1] <= -1; end clk or negedge reset_n) begin if (reset_n == 0) edge_capture[2] <= 0; else if (clk_en) if (edge_capture_wr_strobe) edge_capture[2] <= 0; else if (edge_detect[2]) edge_capture[2] <= -1; end clk or negedge reset_n) begin if (reset_n == 0) edge_capture[3] <= 0; else if (clk_en) if (edge_capture_wr_strobe) edge_capture[3] <= 0; else if (edge_detect[3]) edge_capture[3] <= -1; end clk or negedge reset_n) begin if (reset_n == 0) begin d1_data_in <= 0; d2_data_in <= 0; end else if (clk_en) begin d1_data_in <= data_in; d2_data_in <= d1_data_in; end assign edge_detect = ~d1_data_in & d2_data_in; endmodule

16 Seven Segment Display: Pin assignment Shown above the pin assignments for segment digit 0 only

17 Seven Segment Display: Pin assignment

18 Cont.

19 Seven segment module SEG7_LUT(oSEG,iDIG); input[3:0]iDIG; output[6:0]oSEG; reg[6:0]oSEG; begin case(iDIG) 4'h1: oSEG = 7'b ;// ---t---- 4'h2: oSEG = 7'b ; // | | 4'h3: oSEG = 7'b ; // lt rt 4'h4: oSEG = 7'b ; // | | 4'h5: oSEG = 7'b ; // ---m---- 4'h6: oSEG = 7'b ; // | | 4'h7: oSEG = 7'b ; // lb rb 4'h8: oSEG = 7'b ; // | | 4'h9: oSEG = 7'b ; // ---b---- 4'ha: oSEG = 7'b ; 4'hb: oSEG = 7'b ; 4'hc: oSEG = 7'b ; 4'hd: oSEG = 7'b ; 4'he: oSEG = 7'b ; 4'hf: oSEG = 7'b ; 4'h0: oSEG = 7'b ; endcase end endmodule

20 LCD controller E R/W RS DB7–DB0 LCD controller communications bus microcontroller 8 void WriteChar(char c){ RS = 1; /* indicate data being sent */ DATA_BUS = c; /* send data to LCD */ EnableLCD(45); /* toggle the LCD with appropriate delay */ }

21 Altera DE2 LCD module The LCD module has built- in fonts and can be used to display text by sending appropriate commands to the display controller (HD44780).

22 LCD module: Pin assignments

23 Lcd_16207.v module lcd_16207_0 ( // inputs: address, begintransfer, read, write, writedata, // outputs: LCD_E, LCD_RS, LCD_RW, LCD_data, irq, readdata ); output LCD_E; output LCD_RS; output LCD_RW; inout [ 7: 0] LCD_data; output irq; output [ 7: 0] readdata; input [ 1: 0] address; input begintransfer; input read; input write; input [ 7: 0] writedata; wire LCD_E; wire LCD_RS; wire LCD_RW; wire [ 7: 0] LCD_data; wire irq; wire [ 7: 0] readdata; assign LCD_RW = address[0]; assign LCD_RS = address[1]; assign LCD_E = read | write; assign LCD_data = (address[0]) ? 8'bz : writedata; assign readdata = LCD_data; //control_slave, which is an e_avalon_slave endmodule