RE: (HLS) Why does Verilog pointer requires two clocks to get updated??

In HLS (2015.2), I created a simple comparator circuit. The HLS C-simulation worked fine. The HLS C-function compares
8-bit integers received from an 8-bit data bus against a fixed array of 8-bit integers. If the first integer matches, a pointer is incremented, and the C-function will then look for the 2nd integer in the array. If the sequence of 8-bit integers on the data
bus matches the sequence of bytes in the stored array, a  match is detected.
After observing a good C-simulation, I instantiated the HLS Verilog file code into the original manually generated top-level
chip Verilog code, and attempted a Modelsim simulation. It did not work!!
The HLS generated Verilog file has the ports below:
ap_clk
ap_rst
ap_start
ch(7:0)   <---    This is the incoming 8-bit data bus.
ch_valid   <----   This is an input that indicates the ch(7:0) data bus has valid data.
ap_return   <---   This is the match signal.
If ch_valid is HIGH, the comparator compares ch(7:0) data bus against the known internal fixed array of 8-bit integers. The
ch(7:0) data bus changes every ap_clk. The problem with the HLS verilog code is that two clock cycles are needed to update the pointer, which points to the next integer in the fixed array. For the HLS circuit to work properly, the ch(7:0) data bus can't change every clock-cycle. The ch(7:0) data bus needs to be stable for 2-clock cycles. The only reason I found this was
due to the ModelSim simulation. In the C-code below, the fixed array is "pattern0", while the pointer is "check0."
int compare (uint8_t ch, int ch_valid, int sop)
uint8_t pattern0[24] = {0xaa, 0xbb, 0xcc, 0xdd, 0x12, 0x34, 0x56, 0x78, 0x11, 0x11, 0x22, 0x22, \
                                0x33, 0x33, 0x44, 0x44, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, 0x55, 0x55};
static int prematch0 = 0, check0 = 0, match0 = 0;
int j;
if (ch_valid == 1) {
    if(check0 < sizeof(pattern0)){
         if(ch == pattern0[check0]) {
            prematch0 = 1;
            check0 = check0+1;
         else {
             prematch0 = 0;
             check0 = 0;
     else if ((check0 == sizeof(pattern0)) && (prematch0 == 1)) {
          check0 = check0;
          match0 = 1;
          prematch0 = 1;
     else {
          check0 = check0;
          match0 = match0;
          prematch0 = prematch0;
else {
       check0 = check0;
       match0 = match0;
       prematch0 = prematch0;
return (match0);
If I write this code manually in Verilog, the check0 pointer is updated in one clock cycle.
Questions:
Why does HLS need two clock cycles to update the check0 pointer?
Do I need to set an HLS directive to cause the verilog code to be generated in a different way?
Does the C-code need to be written differently?
Thanks,
Roy

Hi Debraj,
Thanks for the response. I have another question.
I quicly took the C-code above and added a Verilog clock statement.  The code below would execute in one clock.
Is there any way I can re-write the C-code to reduce the 2cc down to 1cc, or is this not possible?
always @(posedge ap_clk) {
   if (ch_valid == 1) {
       if(check0 < sizeof(pattern0)){
            if(ch == pattern0[check0]) {
                prematch0 = 1;
                check0 = check0+1;
            else {
                prematch0 = 0;
                check0 = 0;
       else if ((check0 == sizeof(pattern0)) && (prematch0 == 1)) {
            check0 = check0;
            match0 = 1;
            prematch0 = 1;
       else {
            check0 = check0;
            match0 = match0;
            prematch0 = prematch0;
    else {
       check0 = check0;
       match0 = match0;
       prematch0 = prematch0;
Thanks,
Roy

Similar Messages

  • Why does it take over two hours to download a movie on Apply tv

    Why does it take over two hours to download a  movie on Apple TV
    Thanks

    Welcome to the Apple Community.
    The first thing to check would be your internet download speed, you can do this at www.speedtest.net.
    1080p HD movies require a recommended speed of 8 Mbps, 720p HD movies require a recommended speed of 6 Mbps, while SD movies require a recommended speed of 2.5 Mbps.
    Netflix uses adaptive streaming and can reduce quality right down to produce a stream as low as 0.5 Mbps.

  • Why does my file requiring ActiveX cant run in my Apple computer?

    Why does my file requiring an ActiveX cannot run in my Apple computer?

    Active X is chiefly a Windows > Internet Explorer browser based function and there is no Internet Explorer for OS X.
    The only way you can run this Active X script is install Windows into Apple's BootCamp dual boot partition solution or by running Windows in a virtual machine program in OS X itself.
    Windows in BootCamp or Virtual Machine?
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents

  • Why does it take for a month to get internet services?

    I'd like to know why does it take for a month to get internet services? I ordered my service on Jan 18,2012 and I got the installation kit on Jan 21,2012. But I can't  use the internet and I have to wait until Feb 9,2012 for my service ready date. I think it takes a long time. I need the internet to do my project, but I can't. I'm very disappointed right now. I think I can use the internet after I place my order. (2 or 3 days it's ok, but I have to wait for a month that's terrible) Why can't they just turn on the services? I'd like to know who can i talk with? 

    Have you tried hooking the modem up, and does it get sync and does the Internet light come on? Even though you technicaly shouldn't do this, the line might already be up and running but they haven't told you yet. I don't know why it takes a month to hook up DSL. In my area, it takes two weeks typically from order to live, whether it's new service or a speed upgrade/downgrade (these are usually one week. They can be done on the spot, though!). No one has ever explained why it takes that long, but I presume it has someting to do with the billing cycle and perhaps line conditioning if they still do that (away from removing bridged taps and load coils), giving a technician time to pick up the service request and perform the task before someone goes, builds the profile for the line and then connects a few cables to an empty slot in a DSLAM and does some other background tasks to bring the connection online.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • What is the colored spinning disk, and why does it appear, and how do I get rid of it?

    What is the colored spinning disk, and why does it appear, and how do I get rid of it?

    Repairing permissions will help as will running the UNIX commands. This widget will do all but the pram.
    http://db.tt/Lob4XtPB  Maintenance Widget  One of those links will get you the widget.
    To reset the pram hold the Command+Option+P+R when starting up, wait through 4 startup sounds before letting go.

  • Why does my 4g and 3gs i phone get my message when its not group message?

    why does my 4g and 3gs i phone get my messages,same household but not group message same apple itune account thou.

    On each device check the following in the Settings app.
    Settings > Messages > Send and Receive
    Make sure the proper phone numbers and/or email address is selected on each. Deselect those that you don't want to use an a particular device.

  • Why does Flash Player keep sending me notifications to update to the version I already have?

    Why does Flash Player keep sending me notifications to update to the version I already have? The result is always an error message telling me that the version is already running. (Desktop Computer; Windows Vista OS; Firefox; Adobe Flash Version 11.8.800.94)

    I don't know; can you post a screenshot of such a notification?
    Did you update both ActiveX (for Internet Explorer) and plugin (for Firefox)?

  • Why does it take 18 hours to install security update 2013-002 onto my macbook pro 10.6.8 safari?

    why does it take 18 hours to install security update 2013-002 onto my macbook pro 10.6.8 safari?

    Are you connected by ethernet, Magsafe or using wifi? 

  • Why does my Iphone 5 ring when I get a call, but can not figure out why there is NO sound when I get a text?

    Why does my Iphone 5 ring when I get a call, but can't not figure out why it does not make a sound, when I receive a text or typing???

    Deborah,
    The solutions on here did not work for me.   I tried.....
    I have the same problem with a BRAND NEW iPhone 5c version 7.1- no sound when a text message arrives.
    (1) I have "do not disturb" scheduled correctly.   No partial moon on the main screen near the time and battery indicator.
    (2) I have the ringer icon correct with no slash.    Yes I turned the hardward mute switch to the UP position (ie the one above the + and - buttons on the left side.   I tried messaging with the bell as shown and bell with a slash and neither work.   The mute switch is not red (switch above the + volume hardware switch)     I enabled some assistant using the Settings menu.    And I press the dot (looks like a target symbol) and go to Devices and I can see what position the bell is in....either a bell with a slash or no slash.
    (3) Yes ringtones are configured for text and other. I can hear them when I am under settings > sounds.   But they do not link with the actual hardware.
    (4) I rebooted the iPhone 5c by using the button at top, slide the red bar, then pressed it again, apple came up for a minute and it seemed to be back up.
    (5) I upgraded the IPhone 5c from 7.0.4 to 7.1 using my pc and itunes.   And the upgrade was successful but did not fix the text issue.
    (6) I do not have it in airplane mode or silent mode.
    (7) I reset all settings using Setttings > General > reset > reset all settings .  this wipes settings but not data and media.
    This is really frustrating.

  • Why does itunes crash upon opening after the software update?

    Why does itunes crash upon opening after the software update? Everything worked fine until I decided to update this morning and as soon as the computer rebooted, the error message appeared.  Is there anything available to fix this?

    I answered the same question in a similar post.  It's all to do with the wireless sync. 
    I used the following method to stop iTunes from constantly restarting -
    Open task manager
    Select the 'Processes' tab.
    Look for 'iTunesHelper.exe'
    Select 'iTunesHelper.exe'  then click on 'end process'
    Hope this helps.

  • HT4623 Why does my iPhone 4 not have the Software update option when I go into the settings?

    Why does my iphone 4 not have the Software update option when I go into my settings to get updates?

    That was made available in iOS 5. To update, you may need to connect to iTunes

  • Why does my system hang on a blank software update screen after I shut down?

    Why does my system hang on a blank software update screen after I shut down the computer?
    This only happened after my computer attempted to download security update 2013-003 version 1.
    I have an iMac with a 2.16 GHz Intel Core 2 Duo running on OSX 10.7.5.
    I repaired all disk permission, and then verified and fixed the disk.
    My hardware diagnostics program gave all systems a green light.
    After all this, the system still hangs.
    This must be an operating system glitch.
    How do I fix it?
    If you tell me to reload the operating system, then I'll have to go retro with Snow Leopard.
    All subsequent updates were purchased from Apple on the Internet and downloaded.

    Cineast wrote:
    If you tell me to reload the operating system, then I'll have to go retro with Snow Leopard.
    All subsequent updates were purchased from Apple on the Internet and downloaded.
    Not so. You use the recovery mode to reinstall Lion. Details in Recovery and About OS X Recovery. Also, see Computers using Internet Recovery.

  • How does the field CCSOFTLOCK in T000 Table get Updated ?

    Hello Experts !
    I would like to know how does the field CCSOFTLOCK in Table T000 Get updated ?
    I tried all fields in SCC4 for a client but none of my change updates CCSOFTLOCK .
    The Data Element Description says   Client control: Soft Lock Required (Planned for 4.0)
    What does this Planned for 4.0 Indicate. We are in ECC5.0.System.
    Regards,
    Mithun Shetty

    Hi Mithun,
    Can you check if Note "1047952 - SCC4: Client settings with enhanced security options "is  applied to your system.
    as per it , you can put additional restrtictions for modifying SCC4 (table T000) fields ,a BadI will be checked additionally.
    15. Parameter : CCCOPYLOCK_VAL_DEFAULT
           Type      : Exporting
           Pass Value : Check
           Optional  : Space
           Associated type: TYPE
           Reference Type : CCSOFTLOCK
    Regards,

  • Why does Bridge CS6 require TMP to point to the C: drive?

    After much hassle I got Photoshop to work but Bridge always fails with the message
    "Failed to write to temporary folder (V:\tmp). Please change the
    environmental variable TMP to an existed folder on the C: drive"
    Ignoring the questionable grammer for the moment why does Bridge care where my
    TMP directory is? CS5 doesn't care. None of the other programs installed on this
    system care. Bridge is absolutely adamant, though. Give it temp space on C: it's
    perfectly happy. Put it anywhere else and no way at all... Where was Adobe QA when
    this was tested??
    Tom

    Their vision of releasing a high quality product was, shall we say, clouded. 
    Geek translation:  More and more companies figure they can release whatever they have on hand and fix it later via the software update process through "the cloud".
    Thinking clouded by the promise of quick profits.
    -Noel

  • HT5824 Why does my iPhone require 27 hours to backup to the iCloud??????????????

    Why does my iPhone 5 require 27 hours to backup to the iCloud???????

    It depends on your upload speed which is normally very slow.
    Subsequent backup should be a lot faster (incremental backup)

Maybe you are looking for