Forum Discussion
Altera_Forum
Honored Contributor
15 years ago>>The guide I mentioned says that each component has to have a *_sw.tcl script (generated by SOPC). However, the script I have is *_hw.tcl.
I believe you have to create your own *_sw.tcl file. It's been awhile since I've done this (Quartus Version 9.0) . It is documented on the Altera website somewhere. I was able to struggle through it. SOPC builder will copy this to your project, I believe. And (at least when I was doing it), I recall that I needed to create my own class.ptf file. That was NOT documented. SOPC builder did not create one for me. Perhaps it does now. Here's my directory structure of a driver I made that worked that I called altera_avalon_hdlc_receiver. Volume in drive C has no label. Volume Serial Number is 6C04-034A Directory of C:\altera\IP\altera_avalon_hdlc_receiver 09/23/2010 03:51 AM <DIR> . 09/23/2010 03:51 AM <DIR> .. 05/07/2009 12:04 PM 1,353 altera_avalon_hdlc_receiver_sw.tcl 05/07/2009 03:42 PM 161 class.ptf 06/01/2010 12:19 AM <DIR> HAL 06/01/2010 12:19 AM <DIR> hdl 06/01/2010 12:19 AM <DIR> inc 09/23/2010 03:51 AM 0 output.txt 3 File(s) 1,514 bytes Directory of C:\altera\IP\altera_avalon_hdlc_receiver\HAL 06/01/2010 12:19 AM <DIR> . 06/01/2010 12:19 AM <DIR> .. 06/01/2010 12:19 AM <DIR> inc 06/01/2010 12:19 AM <DIR> src 0 File(s) 0 bytes Directory of C:\altera\IP\altera_avalon_hdlc_receiver\HAL\inc 06/01/2010 12:19 AM <DIR> . 06/01/2010 12:19 AM <DIR> .. 05/10/2009 11:27 PM 3,031 altera_avalon_hdlc_receiver.h 1 File(s) 3,031 bytes Directory of C:\altera\IP\altera_avalon_hdlc_receiver\HAL\src 06/01/2010 12:19 AM <DIR> . 06/01/2010 12:19 AM <DIR> .. 05/10/2009 11:25 PM 5,723 altera_avalon_hdlc_receiver.c 05/07/2009 12:39 PM 151 component.mk 2 File(s) 5,874 bytes Directory of C:\altera\IP\altera_avalon_hdlc_receiver\hdl 06/01/2010 12:19 AM <DIR> . 06/01/2010 12:19 AM <DIR> .. 05/14/2009 03:59 AM 4,630 HDLC_Receive.v 05/14/2009 03:58 AM 4,631 HDLC_Receive.v.bak 05/14/2009 04:00 AM 4,243 hdlc_receiver_avalon.v 05/14/2009 12:29 AM 4,317 hdlc_receiver_avalon.v.bak 05/14/2009 12:30 AM 3,632 hdlc_receiver_avalon_hw.tcl 05/11/2009 08:31 PM 3,927 hdlc_receiver_avalon_hw.tcl~ 05/12/2009 03:08 AM 6,265 HDLC_receive_top.v 05/12/2009 03:01 AM 6,265 HDLC_receive_top.v.bak 8 File(s) 37,910 bytes Directory of C:\altera\IP\altera_avalon_hdlc_receiver\inc 06/01/2010 12:19 AM <DIR> . 06/01/2010 12:19 AM <DIR> .. 05/10/2009 11:26 PM 3,244 altera_avalon_hdlc_receiver_regs.h 1 File(s) 3,244 bytes Total Files Listed: 15 File(s) 51,573 bytes 17 Dir(s) 27,238,227,968 bytes free altera_avalon_hdlc_receiver_sw.tcl looks like this:# # altera_avalon_hdlc_receiver_driver.tcl# # Create a new driver create_driver altera_avalon_hdlc_receiver_driver# Associate it with some hardware known as "altera_avalon_hdlc_receiver" set_sw_property hw_class_name altera_avalon_hdlc_receiver# The version of this driver set_sw_property version 9.0# This driver may be incompatible with versions of hardware less# than specified below. Updates to hardware and device drivers# rendering the driver incompatible with older versions of# hardware are noted with this property assignment.# # Multiple-Version compatibility was introduced in version 7.1;# prior versions are therefore excluded. set_sw_property min_compatible_hw_version 7.1# Initialize the driver in alt_sys_init() set_sw_property auto_initialize true# Location in generated BSP that above sources will be copied into set_sw_property bsp_subdirectory drivers# # Source file listings...# # C/C++ source files add_sw_property c_source HAL/src/altera_avalon_hdlc_receiver.c# Include files add_sw_property include_source HAL/inc/altera_avalon_hdlc_receiver.h add_sw_property include_source inc/altera_avalon_hdlc_receiver_regs.h# This driver supports HAL & UCOSII BSP (OS) types add_sw_property supported_bsp_type HAL add_sw_property supported_bsp_type UCOSII# End of file class.ptf looks like this: CLASS altera_avalon_hdlc_receiver { MODULE_DEFAULTS { class = "altera_avalon_hdlc_receiver"; class_version = "7.080900"; } } You will have to add the source path to your driver in NIOS II workspace or your program won't find it when you try to# include the .h files. In your case, you will need to write the fopen, fwrite, fread routines to deal with your custom device. I remember reading documentation on this subject. That's about all I can help. I haven't done this in awhile. All I can suggest is read until you are blue in the face. Then read some more. It IS possible, and MUCH nicer to abstract your IORD/IOWR commands in your driver. Using these commands in your main code is a programming sin, in my opinion. Good luck!