element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
7-Segment Display
  • Challenges & Projects
  • Project14
  • 7-Segment Display
  • More
  • Cancel
7-Segment Display
Blog 7 segment display co-design
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: pandoramc
  • Date Created: 23 Apr 2022 11:43 PM Date Created
  • Views 7219 views
  • Likes 10 likes
  • Comments 2 comments
  • 7segmentdisplaych
  • hardware
  • 7segmentdisplay
  • 7segmentdisplaysch
  • nios ii
  • software
Related
Recommended

7 segment display co-design

pandoramc
pandoramc
23 Apr 2022

The following example of 7 segment display is implemented in an FPGA by hardware/software co-design. The video shows that the system has an ascend/descent control and reset button.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Video demo of the co-design function

How is this achieved? There are two designs: architecture and software. The architecture, shown below, consists of two Parallel Input Output (PIO) peripherals. One of these peripherals is mapped to 7 segment displays, in this case, with dot point. The other one is mapped to a switches group to acquire external information to control the direction of counting.

image

Architecure implemented. It consist of NiosII/e, on-chip RAM Memory with 32768 bytes, JTAG interface for debug and programming, and two PIO instances.

The board used is a STEP FPGA MAX 10 with a 10MSAM08 device. This device has 8K Logic Elements (LE), 378Kb of M9K Memory, sufficient to instantiate a Nios II/e processor and the peripherals for this work. In addition, a PLL is needed to meet clock requirements for a JTAG instance because the clock available has a 12MHz oscillation. Finally, the on-chip memory for instruction storage has 32768 bytes. This configuration requires 21% of available logic elements and 71% of memory.

According to the STEP FPGA Hardware Manual, the pin assignment for each device is the following,

image

STEP FPGA pin Assignment. The implemented logic is positive

Only the 12M clock, Switch, and Digital Display 1 assignments are required here. The 12MHz is the clock source for the PLL and a 50MHz clock source is generated. It is possible to use the Pin Planner interface to create interactively the device mapping. Another form to do device mapping is with the Assignment Editor or by a .qsf file. In addition, a button must be mapped to reset the system.

image

Pin Planner with device mapping. Only 16% of pins are required for this implementation

To create the co-design, the architecture must be instantiated and mapped according to the pin assignments, consequently, a small HDL file is required to compile the Hardware, map, and create the Application with its Board Support Package (BSP).

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity step_nios is
	port(	PCLK	: in	std_logic;
			KEY	: in	std_logic_vector(3 downto 0);
			SW		: in	std_logic_vector(3 downto 0);
			HEX0	: out	std_logic_vector(8 downto 0));
end step_nios;

architecture arch_interface of step_nios is

	component base_arch is
		port (
			clk_clk                          : in	std_logic                    := '0';
			hex_0_external_connection_export : out std_logic_vector(8 downto 0);
			pll_areset_conduit_export        : in  std_logic                    := '0';
			reset_reset_n                    : in  std_logic                    := '0';
			sw_external_connection_export    : in  std_logic_vector(3 downto 0) := (others => '0')
		);
	end component base_arch;

begin

	u0: base_arch
		port map(
			clk_clk									=> PCLK,
			hex_0_external_connection_export => HEX0,
			reset_reset_n                    => KEY(0),
			sw_external_connection_export    => SW
		);

end arch_interface;

On the software side, the C bare metal base code to control the display and direction takes the base address of peripherals to read and write data.

#include <stdint.h>
#include <unistd.h>
#include "system.h"

uint32_t codes[10] =	{	0b010111111,//0
							0b000000110,//1
							0b011011011,//2
							0b001001111,//3
							0b011100110,//4
							0b001101101,//5
							0b011111101,//6
							0b000000111,//7
							0b011111111,//8
							0b001101111//9
						};

int main(void){
	uint32_t *hex0 = (uint32_t*)HEX_0_BASE;
	uint32_t *sw = (uint32_t*)SW_BASE;
	int8_t i = 0;
	uint32_t input = 0;
	while (1){
		*hex0 = codes[i];
		input = *sw & 0x0001;
		if(1 == input){
			i++;
		}else{
			i--;
		}
		if(i >= (int8_t)(sizeof(codes)/sizeof(codes[0]))){
			i = 0;
		}else if(i < 0){
			i = sizeof(codes)/sizeof(codes[0]) - 1;
		}
		usleep(250000);
	}
	return 0;
}

  • Sign in to reply
Parents
  • robogary
    robogary over 3 years ago

    Nice. I really like your uint32_t codes[10]  table is binary rather than hex. It makes the code much easier to read.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • robogary
    robogary over 3 years ago

    Nice. I really like your uint32_t codes[10]  table is binary rather than hex. It makes the code much easier to read.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • pandoramc
    pandoramc over 3 years ago in reply to robogary

    Thanks. If you have any doubt or recommendations to improve the content, don't hesitate to post it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube