CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    C++ Program Help - 6 Stage Pseudo Dummy Pipeline

    Hello,

    This is for a course in which the instructor is lacking with regards to help and overall description of the project. We are to create a 6 Stage Pipeline which is as follows: Stage (1) - Instruction Fetch, Stage (2) - Instruction Decode, Stage (3) - Instruction Dispatch, Stage (4) - Instruction Issue, Stage (5) - Instruction Execution, and Stage (6) - Instruction Write-Back.

    Unfortunately, my partner and I are both on the Hardware side of Electrical Engineering and not the Computer side. Therefore, we both have limited coding knowledge and by that I mean extremely basic.

    We were to first code a one stage pipeline...I will include the code here, however we have been having problems with getting it to compile in Visual Studio 2005 because of an error saying that "stdafx.h" is not found.

    Code:
    // hw3.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    
    
    #include <iostream>
    #include <iomanip>
    
    void stage()
    {
     	char Sn_valid_out = 0;
     	char Sn_cmd_out = 0;
     	char Sn_cmd_in = 1;
     	char Sn_valid_in = 1;
     	char Sn_bf = 35;			//this must be a 32-bit array
     	char Sn_data_out1 = 0;
     	char Sn_data_in1 = 0;
     	int clk = 1;
    
    	for(int x = 31; x>=0; x--)
    	{
     		if (clk == '1')
     		{
     			//rising edge of the clock
     			if (Sn_cmd_out == '1')
     			{
     				Sn_valid_out = '0';
     			} 	
     			else
     			{
     			if (Sn_valid_out == '0' && Sn_cmd_in =='1')
     			{
     				Sn_valid_out = '1';
     				Sn_bf = Sn_data_in1;
     			}
     		}
     		clk = 0; //toggle the clock value
     		}
    
     		if (clk == '0')
     		{
     			//falling edge of clock
     			if (Sn_cmd_out == '1')
     			{
     				if (Sn_valid_in == '1')
     				{
     					Sn_cmd_out = '0';
     				}
     			}
     			else 
    			{
     				if (Sn_valid_out == '1')
     				{
    					//you will need to replace an associated procedure of your specific pipeline
    					//stage here
     					printf("lions tigers bear oh my!!!!!!!!!");
    			 
     					Sn_data_out1 = Sn_bf;
     					Sn_cmd_out = '1';
     				}
     			}
     			clk = 1; //toggle the clock value
     		}
    
    	}
    }
    Any help would be greatly appreciated. Thank you in advance!

  2. #2
    Join Date
    Aug 2008
    Posts
    902

    Re: C++ Program Help - 6 Stage Pseudo Dummy Pipeline

    I'm confused. Are you writing a processor emulator at a logical level?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured